From 86791707cd12064a1e69abeedaacaf34e0db9d82 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Sun, 8 Dec 2013 11:31:23 +0100 Subject: [PATCH 01/11] fix export so no tags are omitted --- src/node/utils/ExportHtml.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index 5179adf6..a58c4886 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -251,33 +251,24 @@ function getHTMLFromAtext(pad, atext, authorColors) propVals[i] = true; // set it back } } + // now each member of propVal is in {false,LEAVE,ENTER,true} - // according to what happens at start of span + // false if not in this and not in previous, LEAVE if in previous, ENTER if new or true if + // in this and in the previous + // propChanged is true if any tag should be closed/opened if (propChanged) { - // leaving bold (e.g.) also leaves italics, etc. - var left = false; for (var i = 0; i < propVals.length; i++) { var v = propVals[i]; - if (!left) + if (v === true && propVals.indexOf(LEAVE) != -1) { - if (v === LEAVE) - { - left = true; - } - } - else - { - if (v === true) - { - propVals[i] = STAY; // tag will be closed and re-opened - } + propVals[i] = STAY; // tag will be closed and re-opened } } + // close all tags that are open in previous op but not in this one var tags2close = []; - for (var i = propVals.length - 1; i >= 0; i--) { if (propVals[i] === LEAVE) From 70c51d731b045edcdfe16ed4bbbf48b427b36d92 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Sun, 8 Dec 2013 11:33:20 +0100 Subject: [PATCH 02/11] add some documentation for styling attributes export --- src/node/utils/ExportHtml.js | 25 ++++++++++++++++++++++--- 1 file 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+=""; } + // 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 Date: Sun, 8 Dec 2013 11:34:11 +0100 Subject: [PATCH 03/11] some more docs for attribute export and cleanup empty lines --- src/node/utils/ExportHtml.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index b5a03757..53e27cc7 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -92,24 +92,24 @@ function getHTMLFromAtext(pad, atext, authorColors) if(authorColors){ css+="