From 6ca2c91fdf412358ffb71a1bf298bb8705b96308 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Sun, 28 Dec 2014 02:32:53 +0100 Subject: [PATCH] close and open lists according to the actual line.listLevel --- src/node/utils/ExportHtml.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index 3e42b88b1..bb29b34d3 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -332,12 +332,23 @@ function getHTMLFromAtext(pad, atext, authorColors) pieces.push('') } 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(toOpen > 0){ + pieces.push(new Array(toOpen + 1).join('
    ')) + } pieces.push('
    1. ', lineContent || '
      '); } else { + if(toOpen > 0){ + pieces.push(new Array(toOpen + 1).join('
        ')) + } pieces.push('
        • ', lineContent || '
          '); } } @@ -383,28 +394,19 @@ function getHTMLFromAtext(pad, atext, authorColors) pieces.push('
        • ', lineContent || '
          '); } } - else//outside any list + else//outside any list, need to close line.listLevel of lists { if(lists.length > 0){ if(lists[lists.length - 1][1] == "number"){ pieces.push('
    '); + pieces.push(new Array(lists[lists.length - 1][0]).join('
')) } else { pieces.push(''); + pieces.push(new Array(lists[lists.length - 1][0]).join('')) } - lists.length--; - } - while (lists.length > 0)//if was in a list: close it before - { - if(lists[lists.length - 1][1] == "number") - { - pieces.push(''); - } - else - { - pieces.push(''); - } - lists.length--; } + lists = [] + var lineContentFromHook = hooks.callAllStr("getLineHTMLForExport", { line: line,