From 16365557b20c7efc689f3c6bf8e66882015df76b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Mon, 15 Apr 2013 15:39:15 +0200 Subject: [PATCH] First naive implementation of transformations.toXML.getXML --- modules/visualEditor.transformations.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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(); + } } -- 2.20.1