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.util.UUID;
import javax.jcr.ImportUUIDBehavior;
import javax.jcr.Item;
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.ParserConfigurationException;
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.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();
+ private String linkCssClass = DbkType.link.name();
+
@Override
public void write(Item item, String content) {
try {
} 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>");
}