diff options
author | webzwo0i <webzwo0i@c3d2.de> | 2013-12-08 11:33:20 +0100 |
---|---|---|
committer | webzwo0i <webzwo0i@c3d2.de> | 2013-12-08 11:33:20 +0100 |
commit | 70c51d731b045edcdfe16ed4bbbf48b427b36d92 (patch) | |
tree | 273cbf38c2d3589421ac8ad3bcb139405214509f /src/node | |
parent | 86791707cd12064a1e69abeedaacaf34e0db9d82 (diff) | |
download | etherpad-lite-70c51d731b045edcdfe16ed4bbbf48b427b36d92.zip |
add some documentation for styling attributes export
Diffstat (limited to 'src/node')
-rw-r--r-- | src/node/utils/ExportHtml.js | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index a58c4886..b5a03757 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -79,6 +79,10 @@ function getHTMLFromAtext(pad, atext, authorColors) var tags = ['h1', 'h2', 'strong', 'em', 'u', 's']; var props = ['heading1', 'heading2', 'bold', 'italic', 'underline', 'strikethrough']; + // holds a map of used styling attributes (*1, *2, etc) in the apool + // and maps them to an index in props + // *3:2 -> the attribute *3 means strong + // *2:5 -> the attribute *2 means s(trikethrough) var anumMap = {}; var css = ""; @@ -113,10 +117,12 @@ function getHTMLFromAtext(pad, atext, authorColors) "}\n"; } } - + css+="</style>"; } + // iterates over all props(h1,h2,strong,...), checks if it is used in + // this pad, and if yes puts its attrib id->props value into anumMap props.forEach(function (propName, i) { var propTrueNum = apool.putAttrib([propName, true], true); @@ -128,7 +134,10 @@ function getHTMLFromAtext(pad, atext, authorColors) function getLineHTML(text, attribs) { - var propVals = [false, false, false]; + // the current state of every attrib + // false if a tag was not seen or after it was pushed to tags2close + // true after emitOpenTag was called + var propVals = [false, false, false, false, false, false]; //every supported attrib var ENTER = 1; var STAY = 2; var LEAVE = 0; @@ -188,7 +197,15 @@ function getHTMLFromAtext(pad, atext, authorColors) assem.append('>'); } } - + + // this function takes an array of tags that should be closed + // it iterates over the array of open tags and tags2close and if it + // finds a match, it calls emitCloseTag (which removes and + // closes it) and decreases the iteration counter by one + // this ensures, that multiple tags can be closed: + // opentags = ['strong','em','s'] + // closetags = ['s','em'] + // function orderdCloseTags(tags2close) { for(var i=0;i<openTags.length;i++) @@ -219,6 +236,8 @@ function getHTMLFromAtext(pad, atext, authorColors) var iter = Changeset.opIterator(Changeset.subattribution(attribs, idx, idx + numChars)); idx += numChars; + // this iterates over every op string and decides which tags to open or to close + // based on the attribs used while (iter.hasNext()) { var o = iter.next(); |