@Override public void characters(String text) { ensureBlockElementsOpen(); super.characters(text); }
@Override public void charactersUnescaped(String literal) { ensureBlockElementsOpen(); // note: this *may* have HTML tags in it writer.writeLiteral(literal); // Logger.getLogger(DocBookDocumentBuilder.class.getName()).warning("HTML literal not supported in DocBook"); }
@Override public void lineBreak() { ensureBlockElementsOpen(); // no equivalent in DocBook. characters("\n"); //$NON-NLS-1$ }
@Override public void image(Attributes attributes, String url) { ensureBlockElementsOpen(); String cssClass = attributes.getCssClass(); boolean inlined = false; if (cssClass != null && CSS_CLASS_INLINE.matcher(cssClass).find()) { inlined = true; } emitImage(attributes, url, inlined); }
@Override public void entityReference(String entity) { ensureBlockElementsOpen(); if (entity.startsWith("#")) { //$NON-NLS-1$ String numeric = entity.substring(1); int base = 10; if (numeric.startsWith("x")) { //$NON-NLS-1$ numeric = entity.substring(1); base = 16; } int unicodeValue = Integer.parseInt(numeric, base); if (entityReferenceToUnicode.contains(unicodeValue)) { writer.writeCharacters("" + ((char) unicodeValue)); //$NON-NLS-1$ return; } } writer.writeEntityRef(entity); }
private void emitImage(Attributes attributes, String url, boolean inline) { ensureBlockElementsOpen(); writer.writeStartElement(inline ? "inlinemediaobject" : "mediaobject"); //$NON-NLS-1$ //$NON-NLS-2$ applyAttributes(attributes);
private void link(Attributes attributes, String href, ContentEmitter emitter) { ensureBlockElementsOpen(); if (href == null) { writer.writeStartElement("anchor"); //$NON-NLS-1$ if (attributes.getId() != null) { writer.writeAttribute("id", attributes.getId()); //$NON-NLS-1$ } emitter.emit(); writer.writeEndElement(); // anchor } else if (href.startsWith("#")) { //$NON-NLS-1$ if (href.length() > 1) { writer.writeStartElement("link"); //$NON-NLS-1$ writer.writeAttribute("linkend", href.substring(1)); //$NON-NLS-1$ emitter.emit(); writer.writeEndElement(); // link } else { emitter.emit(); } } else { writer.writeStartElement("ulink"); //$NON-NLS-1$ writer.writeAttribute("url", href); //$NON-NLS-1$ emitter.emit(); writer.writeEndElement(); // ulink } }
@Override public void beginSpan(SpanType type, Attributes attributes) { ensureBlockElementsOpen(); switch (type) { case BOLD: