mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
fix closing of lists
This commit is contained in:
parent
8e280f46c1
commit
6e4e034e42
1 changed files with 14 additions and 8 deletions
|
@ -305,10 +305,12 @@ function getHTMLFromAtext(pad, atext, authorColors)
|
||||||
// want to deal gracefully with blank lines.
|
// want to deal gracefully with blank lines.
|
||||||
// => keeps track of the parents level of indentation
|
// => keeps track of the parents level of indentation
|
||||||
var lists = []; // e.g. [[1,'bullet'], [3,'bullet'], ...]
|
var lists = []; // e.g. [[1,'bullet'], [3,'bullet'], ...]
|
||||||
|
var listLevels = []
|
||||||
for (var i = 0; i < textLines.length; i++)
|
for (var i = 0; i < textLines.length; i++)
|
||||||
{
|
{
|
||||||
var line = _analyzeLine(textLines[i], attribLines[i], apool);
|
var line = _analyzeLine(textLines[i], attribLines[i], apool);
|
||||||
var lineContent = getLineHTML(line.text, line.aline);
|
var lineContent = getLineHTML(line.text, line.aline);
|
||||||
|
listLevels.push(line.listLevel)
|
||||||
|
|
||||||
if (line.listLevel)//If we are inside a list
|
if (line.listLevel)//If we are inside a list
|
||||||
{
|
{
|
||||||
|
@ -379,30 +381,34 @@ function getHTMLFromAtext(pad, atext, authorColors)
|
||||||
}*/
|
}*/
|
||||||
else//means we are getting closer to the lowest level of indentation or are at the same level
|
else//means we are getting closer to the lowest level of indentation or are at the same level
|
||||||
{
|
{
|
||||||
while (whichList < lists.length - 1)
|
var toClose = lists.length > 0 ? listLevels[listLevels.length - 2] - line.listLevel : 0
|
||||||
{
|
if( toClose > 0){
|
||||||
|
pieces.push('</li>')
|
||||||
if(lists[lists.length - 1][1] == "number")
|
if(lists[lists.length - 1][1] == "number")
|
||||||
{
|
{
|
||||||
pieces.push('</li></ol>');
|
pieces.push(new Array(toClose+1).join('</ol>'))
|
||||||
|
pieces.push('<li>', lineContent || '<br>');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pieces.push('</li></ul>');
|
pieces.push(new Array(toClose+1).join('</ul>'))
|
||||||
}
|
pieces.push('<li>', lineContent || '<br>');
|
||||||
lists.length--;
|
|
||||||
}
|
}
|
||||||
|
lists = lists.slice(0,whichList+1)
|
||||||
|
} else {
|
||||||
pieces.push('</li><li>', lineContent || '<br>');
|
pieces.push('</li><li>', lineContent || '<br>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else//outside any list, need to close line.listLevel of lists
|
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>'))
|
pieces.push(new Array(listLevels[listLevels.length - 2]).join('</ol>'))
|
||||||
} else {
|
} else {
|
||||||
pieces.push('</li></ul>');
|
pieces.push('</li></ul>');
|
||||||
pieces.push(new Array(lists[lists.length - 1][0]).join('</ul>'))
|
pieces.push(new Array(listLevels[listLevels.length - 2]).join('</ul>'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lists = []
|
lists = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue