Skip to content
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
69bf32c
fix to https://github.com/ether/etherpad-lite/issues/2486
ilmartyrk Oct 19, 2017
c36a326
fix to ether/etherpad-lite#2486
ilmartyrk Oct 20, 2017
724b1d7
updated html export, run hooks also with lists
ilmartyrk Oct 31, 2017
5469ce8
exportHTML update
ilmartyrk Oct 31, 2017
76f211b
ExportHtml.js update
ilmartyrk Nov 1, 2017
3040050
added tiblus ep_prefs_different_cookie_for_different_protocol
ilmartyrk Nov 3, 2017
cf82177
ueberDB2 update
ilmartyrk Mar 26, 2018
6f2466b
Merge with upstream develop.
tiblu Apr 2, 2018
a4819b2
Upgrade Ueberdb2 to 0.3.7 to fix https://github.com/ether/etherpad-li…
tiblu Apr 4, 2018
a67aaa8
Merge remote-tracking branch 'upstream/master' into develop
tiblu Apr 4, 2018
20428bb
Merge remote-tracking branch 'upstream/develop' into develop
tiblu Apr 4, 2018
64a2e5b
Upgrade Ueberdb2 to 0.3.7 to fix https://github.com/ether/etherpad-li…
tiblu Apr 4, 2018
b4ad7cf
Export lists fix + code linting and readability update
ilmartyrk Apr 5, 2018
8502c04
html lists export fix
ilmartyrk Apr 9, 2018
517b249
D
ilmartyrk Apr 9, 2018
d6fa065
export html to original structure
ilmartyrk Apr 24, 2018
7cc7bb1
upgrade to 1.6.5
ilmartyrk Apr 24, 2018
8d27f3c
upgrade to 1.6.5
ilmartyrk Apr 24, 2018
c9863f8
sync with ether/etherpad-lite
ilmartyrk May 2, 2018
55ecf31
html export fix
ilmartyrk May 2, 2018
6684f9b
hook callAll to aCallAll
ilmartyrk May 2, 2018
47e20a2
line parsing fix
ilmartyrk May 2, 2018
016497d
prevLine/nextLine check fix
ilmartyrk May 14, 2018
3c66425
List indent fix
ilmartyrk May 21, 2018
4feccff
merge with develop branch
ilmartyrk May 21, 2018
a96aa88
merge with ether/etherpad-lite develop branch
ilmartyrk May 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 85 additions & 105 deletions src/node/utils/ExportHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ function getHTMLFromAtext(pad, atext, authorColors)
}

// close all tags upto the outer most
if (outermostTag != -1)
if (outermostTag !== -1)
{
while ( outermostTag >= 0 )
{
Expand All @@ -282,7 +282,7 @@ function getHTMLFromAtext(pad, atext, authorColors)
{
if (openTags.indexOf(usedAttribs[i]) === -1)
{
emitOpenTag(usedAttribs[i])
emitOpenTag(usedAttribs[i]);
}
}

Expand All @@ -304,7 +304,7 @@ function getHTMLFromAtext(pad, atext, authorColors)
// close all the tags that are open after the last op
while (openTags.length > 0)
{
emitCloseTag(openTags[0])
emitCloseTag(openTags[0]);
}
} // end processNextChars
if (urls)
Expand Down Expand Up @@ -333,148 +333,128 @@ function getHTMLFromAtext(pad, atext, authorColors)
// so we want to do something reasonable there. We also
// want to deal gracefully with blank lines.
// => keeps track of the parents level of indentation
var lists = []; // e.g. [[1,'bullet'], [3,'bullet'], ...]
var listLevels = []
var openLists = [];
for (var i = 0; i < textLines.length; i++)
{
var context;
var line = _analyzeLine(textLines[i], attribLines[i], apool);
var lineContent = getLineHTML(line.text, line.aline);
listLevels.push(line.listLevel)

if (line.listLevel)//If we are inside a list
{
// do list stuff
var whichList = -1; // index into lists or -1
if (line.listLevel)
context = {
line: line,
lineContent: lineContent,
apool: apool,
attribLine: attribLines[i],
text: textLines[i],
padId: pad.id
};
var prevLine = null;
var nextLine = null;
if (i > 0)
{
whichList = lists.length;
for (var j = lists.length - 1; j >= 0; j--)
prevLine = _analyzeLine(textLines[i -1], attribLines[i -1], apool);
}
if (i < textLines.length)
{
nextLine = _analyzeLine(textLines[i + 1], attribLines[i + 1], apool);
}
hooks.aCallAll('getLineHTMLForExport', context);
//To create list parent elements
if ((!prevLine || prevLine.listLevel !== line.listLevel) || (prevLine && line.listTypeName !== prevLine.listTypeName))
{
var exists = _.find(openLists, function (item)
{
if (line.listLevel <= lists[j][0])
return (item.level === line.listLevel && item.type === line.listTypeName);
});
if (!exists) {
var prevLevel = 0;
if (prevLine && prevLine.listLevel) {
prevLevel = prevLine.listLevel;
}
if (prevLine && line.listTypeName !== prevLine.listTypeName)
{
whichList = j;
prevLevel = 0;
}
}
}

if (whichList >= lists.length)//means we are on a deeper level of indentation than the previous line
{
if(lists.length > 0){
pieces.push('</li>')
for (var diff = prevLevel; diff < line.listLevel; diff++) {
openLists.push({level: diff, type: line.listTypeName});
var prevPiece = pieces[pieces.length - 1];

if (prevPiece.indexOf("<ul") === 0 || prevPiece.indexOf("<ol") === 0 || prevPiece.indexOf("</li>") === 0)
{
pieces.push("<li>");
}

if (line.listTypeName === "number")
{
pieces.push("<ol class=\"" + line.listTypeName + "\">");
}
else
{
pieces.push("<ul class=\"" + 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
pieces.push("<li>", context.lineContent);

if(line.listTypeName == "number")
{
if(toOpen > 0){
pieces.push(new Array(toOpen + 1).join('<ol>'))
}
pieces.push('<ol class="'+line.listTypeName+'"><li>', lineContent || '<br>');
// To close list elements
if (nextLine && nextLine.listLevel === line.listLevel && line.listTypeName === nextLine.listTypeName)
{
pieces.push("</li>");
}
if ((!nextLine || !nextLine.listLevel || nextLine.listLevel < line.listLevel) || (nextLine && line.listTypeName !== nextLine.listTypeName))
{
var nextLevel = 0;
if (nextLine && nextLine.listLevel) {
nextLevel = nextLine.listLevel;
}
else
if (nextLine && line.listTypeName !== nextLine.listTypeName)
{
if(toOpen > 0){
pieces.push(new Array(toOpen + 1).join('<ul>'))
}
pieces.push('<ul class="'+line.listTypeName+'"><li>', lineContent || '<br>');
nextLevel = 0;
}
}
//the following code *seems* dead after my patch.
//I keep it just in case I'm wrong...
/*else if (whichList == -1)//means we are not inside a list
{
if (line.text)

for (var diff = nextLevel; diff < line.listLevel; diff++)
{
console.log('trace 1');
// non-blank line, end all lists
if(line.listTypeName == "number")
openLists = openLists.filter(function(el)
{
pieces.push(new Array(lists.length + 1).join('</li></ol>'));
}
else
return el.level !== diff && el.type !== line.listTypeName;
});

if (pieces[pieces.length - 1].indexOf("</ul") === 0 || pieces[pieces.length - 1].indexOf("</ol") === 0)
{
pieces.push(new Array(lists.length + 1).join('</li></ul>'));
pieces.push("</li>");
}
lists.length = 0;
pieces.push(lineContent, '<br>');
}
else
{
console.log('trace 2');
pieces.push('<br><br>');
}
}*/
else//means we are getting closer to the lowest level of indentation or are at the same level
{
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 (line.listTypeName === "number")
{
pieces.push(new Array(toClose+1).join('</ol>'))
pieces.push('<li>', lineContent || '<br>');
pieces.push("</ol>");
}
else
{
pieces.push(new Array(toClose+1).join('</ul>'))
pieces.push('<li>', lineContent || '<br>');
pieces.push("</ul>");
}
lists = lists.slice(0,whichList+1)
} else {
pieces.push('</li><li>', lineContent || '<br>');
}
}
}
}
else//outside any list, need to close line.listLevel of lists
{
if(lists.length > 0){
if(lists[lists.length - 1][1] == "number"){
pieces.push('</li></ol>');
pieces.push(new Array(listLevels[listLevels.length - 2]).join('</ol>'))
} else {
pieces.push('</li></ul>');
pieces.push(new Array(listLevels[listLevels.length - 2]).join('</ul>'))
}
}
lists = []

var context = {
context = {
line: line,
lineContent: lineContent,
apool: apool,
attribLine: attribLines[i],
text: textLines[i],
padId: pad.id
}

var lineContentFromHook = hooks.callAllStr("getLineHTMLForExport", context, " ", " ", "");
};

if (lineContentFromHook)
{
pieces.push(lineContentFromHook, '');
}
else
{
pieces.push(lineContent, '<br>');
hooks.aCallAll("getLineHTMLForExport", context);
pieces.push(context.lineContent, "<br>");
}
}
}

for (var k = lists.length - 1; k >= 0; k--)
{
if(lists[k][1] == "number")
{
pieces.push('</li></ol>');
}
else
{
pieces.push('</li></ul>');
}
}

return pieces.join('');
}
Expand Down