Introduce showMainTitle property.
[gpl/argeo-suite.git] / publishing / org.argeo.publishing.ui / src / org / argeo / docbook / ui / DbkTextInterpreter.java
index 25056efb7bd5e03b65e43431565583ba56893f54..eafddd9243dddb232afaa4b5b44a0d2f6028358a 100644 (file)
@@ -1,5 +1,9 @@
 package org.argeo.docbook.ui;
 
+import static org.argeo.docbook.DbkUtils.isDbk;
+import static org.argeo.docbook.DbkType.para;
+import static org.argeo.docbook.DbkType.title;
+
 import java.io.IOException;
 import java.io.StringReader;
 import java.util.List;
@@ -23,7 +27,7 @@ public class DbkTextInterpreter implements TextInterpreter {
                try {
                        if (item instanceof Node) {
                                Node node = (Node) item;
-                               if (node.isNodeType(DocBookTypes.PARA) || node.isNodeType(DocBookTypes.TITLE)) {
+                               if (isDbk(node, para) || isDbk(node, title)) {
                                        String raw = convertToStorage(node, content);
                                        validateBeforeStoring(raw);
                                        Node jcrText;
@@ -61,7 +65,7 @@ public class DbkTextInterpreter implements TextInterpreter {
                        item.getSession().refresh(true);
                        if (item instanceof Node) {
                                Node node = (Node) item;
-                               if (node.isNodeType(DocBookTypes.PARA) || node.isNodeType(DocBookTypes.TITLE)) {
+                               if (isDbk(node, para) || isDbk(node, title)) {
                                        Node jcrText = node.getNode(Jcr.JCR_XMLTEXT);
                                        String txt = jcrText.getProperty(Jcr.JCR_XMLCHARACTERS).getString();
                                        // TODO make it more robust
@@ -84,6 +88,22 @@ public class DbkTextInterpreter implements TextInterpreter {
 
        public String readSimpleHtml(Item item) {
                String raw = raw(item);
+               // FIXME the saved data should be corrected instead.
+               if (raw.indexOf('&') >= 0) {
+                       raw = raw.replace("&", "&");
+               }
+               if (raw.indexOf('<') >= 0) {
+                       raw = raw.replace("<", "&lt;");
+               }
+               if (raw.indexOf('>') >= 0) {
+                       raw = raw.replace(">", "&gt;");
+               }
+               if (raw.indexOf('\"') >= 0) {
+                       raw = raw.replace("\"", "&quot;");
+               }
+               if (raw.indexOf('\'') >= 0) {
+                       raw = raw.replace("\'", "&apos;");
+               }
 //             raw = "<span style='text-align:justify'>" + raw + "</span>";
                if (raw.length() == 0)
                        return raw;