mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
close and open lists according to the actual line.listLevel
This commit is contained in:
parent
d71b11f4b2
commit
6ca2c91fdf
1 changed files with 16 additions and 14 deletions
|
@ -332,12 +332,23 @@ function getHTMLFromAtext(pad, atext, authorColors)
|
||||||
pieces.push('</li>')
|
pieces.push('</li>')
|
||||||
}
|
}
|
||||||
lists.push([line.listLevel, line.listTypeName]);
|
lists.push([line.listLevel, line.listTypeName]);
|
||||||
|
|
||||||
|
// if there is a previous list we need to open x tags, where x is the difference of the levels
|
||||||
|
// if there is no previous list we need to open x tags, where x is the wanted level
|
||||||
|
var toOpen = lists.length > 1 ? line.listLevel - lists[lists.length - 2][0] - 1 : line.listLevel - 1
|
||||||
|
|
||||||
if(line.listTypeName == "number")
|
if(line.listTypeName == "number")
|
||||||
{
|
{
|
||||||
|
if(toOpen > 0){
|
||||||
|
pieces.push(new Array(toOpen + 1).join('<ol>'))
|
||||||
|
}
|
||||||
pieces.push('<ol class="'+line.listTypeName+'"><li>', lineContent || '<br>');
|
pieces.push('<ol class="'+line.listTypeName+'"><li>', lineContent || '<br>');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(toOpen > 0){
|
||||||
|
pieces.push(new Array(toOpen + 1).join('<ul>'))
|
||||||
|
}
|
||||||
pieces.push('<ul class="'+line.listTypeName+'"><li>', lineContent || '<br>');
|
pieces.push('<ul class="'+line.listTypeName+'"><li>', lineContent || '<br>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,28 +394,19 @@ function getHTMLFromAtext(pad, atext, authorColors)
|
||||||
pieces.push('</li><li>', lineContent || '<br>');
|
pieces.push('</li><li>', lineContent || '<br>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else//outside any list
|
else//outside any list, need to close line.listLevel of lists
|
||||||
{
|
{
|
||||||
if(lists.length > 0){
|
if(lists.length > 0){
|
||||||
if(lists[lists.length - 1][1] == "number"){
|
if(lists[lists.length - 1][1] == "number"){
|
||||||
pieces.push('</li></ol>');
|
pieces.push('</li></ol>');
|
||||||
|
pieces.push(new Array(lists[lists.length - 1][0]).join('</ol>'))
|
||||||
} else {
|
} else {
|
||||||
pieces.push('</li></ul>');
|
pieces.push('</li></ul>');
|
||||||
|
pieces.push(new Array(lists[lists.length - 1][0]).join('</ul>'))
|
||||||
}
|
}
|
||||||
lists.length--;
|
|
||||||
}
|
|
||||||
while (lists.length > 0)//if was in a list: close it before
|
|
||||||
{
|
|
||||||
if(lists[lists.length - 1][1] == "number")
|
|
||||||
{
|
|
||||||
pieces.push('</ol>');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pieces.push('</ul>');
|
|
||||||
}
|
|
||||||
lists.length--;
|
|
||||||
}
|
}
|
||||||
|
lists = []
|
||||||
|
|
||||||
var lineContentFromHook = hooks.callAllStr("getLineHTMLForExport",
|
var lineContentFromHook = hooks.callAllStr("getLineHTMLForExport",
|
||||||
{
|
{
|
||||||
line: line,
|
line: line,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue