From: Aleksander Ɓukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
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?hp=a22d30b71f012cf8653319e6743440abf7be52a8

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 = $('<div></div>');
+            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 = $('<metadata>');
+            _.each(_.keys(documentDescription.metadata), function(key) {
+                meta.append($('<dc:'+key+'>' + documentDescription.metadata[key] + '</dc:'+key+'>'));
+            });
+            
+            toret.find('document').prepend(meta);
+            
+            return toret.html();
+            
         }
     }