From: Aleksander Ɓukasz Date: Mon, 15 Apr 2013 13:39:15 +0000 (+0200) Subject: First naive implementation of transformations.toXML.getXML X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/16365557b20c7efc689f3c6bf8e66882015df76b First naive implementation of transformations.toXML.getXML --- diff --git a/modules/visualEditor.transformations.js b/modules/visualEditor.transformations.js index 9d21f5d..22deba5 100644 --- a/modules/visualEditor.transformations.js +++ b/modules/visualEditor.transformations.js @@ -52,7 +52,26 @@ if(typeof module !== 'undefined' && module.exports) { transformations.toXML = { getXML: function(documentDescription) { - return documentDescription.HTMLTree; + + var inner = $(documentDescription.HTMLTree); + var toret = $('
'); + toret.append(inner); + + toret.find('div, span').replaceWith(function() { + var div = $(this); + var tagName = div.attr('class').split('rng-')[1]; + return $('<'+tagName+'>').append(div.contents()); + }); + + var meta = $(''); + _.each(_.keys(documentDescription.metadata), function(key) { + meta.append($('' + documentDescription.metadata[key] + '')); + }); + + toret.find('document').prepend(meta); + + return toret.html(); + } }