projects
/
gpl
/
argeo-suite.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Disable markup validation for paragraphs.
[gpl/argeo-suite.git]
/
publishing
/
org.argeo.publishing.ui
/
src
/
org
/
argeo
/
docbook
/
ui
/
DbkTextInterpreter.java
diff --git
a/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/DbkTextInterpreter.java
b/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/DbkTextInterpreter.java
index 17810505057b5c4b1a077c86a1bbe1783c57ae28..c853535440d03f758cccc12f1c0f73cf96afd032 100644
(file)
--- a/
publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/DbkTextInterpreter.java
+++ b/
publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/DbkTextInterpreter.java
@@
-7,11
+7,9
@@
import static org.argeo.docbook.DbkUtils.isDbk;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.Reader;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.List;
-import java.util.UUID;
import javax.jcr.ImportUUIDBehavior;
import javax.jcr.Item;
import javax.jcr.ImportUUIDBehavior;
import javax.jcr.Item;
@@
-20,27
+18,20
@@
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.RepositoryException;
-import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.IOUtils;
-import org.argeo.cms.text.TextInterpreter;
import org.argeo.docbook.DbkAttr;
import org.argeo.docbook.DbkType;
import org.argeo.jcr.Jcr;
import org.argeo.jcr.JcrException;
import org.argeo.docbook.DbkAttr;
import org.argeo.docbook.DbkType;
import org.argeo.jcr.Jcr;
import org.argeo.jcr.JcrException;
-import org.argeo.jcr.JcrxType;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
/** Based on HTML with a few Wiki-like shortcuts. */
public class DbkTextInterpreter implements TextInterpreter {
private DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
/** Based on HTML with a few Wiki-like shortcuts. */
public class DbkTextInterpreter implements TextInterpreter {
private DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ private String linkCssClass = DbkType.link.name();
+
@Override
public void write(Item item, String content) {
try {
@Override
public void write(Item item, String content) {
try {
@@
-208,7
+199,9
@@
public class DbkTextInterpreter implements TextInterpreter {
} else if (child.getName().equals(DbkType.link.get())) {
if (child.hasProperty(DbkAttr.XLINK_HREF)) {
String href = child.getProperty(DbkAttr.XLINK_HREF).getString();
} else if (child.getName().equals(DbkType.link.get())) {
if (child.hasProperty(DbkAttr.XLINK_HREF)) {
String href = child.getProperty(DbkAttr.XLINK_HREF).getString();
- sb.append("<a href=\"").append(href).append("\">");
+ // TODO deal with other forbidden XML characters?
+ href = href.replace("&", "&");
+ sb.append("<a class='" + linkCssClass + "' href='").append(href).append("'>");
readAsSimpleHtml(child, sb);
sb.append("</a>");
}
readAsSimpleHtml(child, sb);
sb.append("</a>");
}
@@
-259,7
+252,10
@@
public class DbkTextInterpreter implements TextInterpreter {
public String readSimpleHtml(Item item) {
try {
StringBuilder sb = new StringBuilder();
public String readSimpleHtml(Item item) {
try {
StringBuilder sb = new StringBuilder();
+// sb.append("<div style='text-align: justify;'>");
readAsSimpleHtml((Node) item, sb);
readAsSimpleHtml((Node) item, sb);
+// sb.append("</div>");
+// System.out.println(sb);
return sb.toString();
} catch (RepositoryException e) {
throw new JcrException("Cannot convert " + item + " to simple HTML", e);
return sb.toString();
} catch (RepositoryException e) {
throw new JcrException("Cannot convert " + item + " to simple HTML", e);