protected String toHtml(String markup) { Writer writer = new StringWriter(); HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer); builder.setEmitAsDocument(false); parser.setBuilder(builder); parser.parse(markup); return writer.toString(); } }
other.setBase(getBase()); other.setBaseInHead(isBaseInHead()); other.setDefaultAbsoluteLinkTarget(getDefaultAbsoluteLinkTarget()); other.setEmitAsDocument(isEmitAsDocument()); other.setEmitDtd(isEmitDtd()); other.setHtmlDtd(getHtmlDtd()); other.setHtmlNsUri(getHtmlNsUri()); other.setLinkRel(getLinkRel()); other.setTitle(getTitle()); other.setUseInlineStyles(isUseInlineStyles()); other.setSuppressBuiltInStyles(isSuppressBuiltInStyles()); other.setXhtmlStrict(xhtmlStrict); other.setPrependImagePrefix(prependImagePrefix); other.setCopyrightNotice(getCopyrightNotice()); other.setHtmlFilenameFormat(htmlFilenameFormat); other.spanTypeToElementName = spanTypeToElementName; copyLinkProcessors(other); if (stylesheets != null) { other.stylesheets = new ArrayList<Stylesheet>();
public void addCssStylesheet(Stylesheet stylesheet) { out.addCssStylesheet(stylesheet); }
@Override public void link(Attributes attributes, String hrefOrHashName, String text) { writer.writeStartElement(htmlNsUri, spanTypeToElementName.get(SpanType.LINK)); emitAnchorHref(hrefOrHashName); applyLinkAttributes(attributes, hrefOrHashName); characters(text); writer.writeEndElement(); }
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer, formatOutput); for (Stylesheet stylesheet : stylesheets) { HtmlDocumentBuilder.Stylesheet builderStylesheet; builderStylesheet = new HtmlDocumentBuilder.Stylesheet(stylesheet.file); builder.addCssStylesheet(builderStylesheet); builder.setTitle(title == null ? name : title); builder.setEmitDtd(emitDoctype); if (emitDoctype && htmlDoctype != null) { builder.setHtmlDtd(htmlDoctype); builder.setUseInlineStyles(useInlineCssStyles); builder.setSuppressBuiltInStyles(suppressBuiltInCssStyles); builder.setLinkRel(linkRel); builder.setDefaultAbsoluteLinkTarget(defaultAbsoluteLinkTarget); builder.setPrependImagePrefix(prependImagePrefix); builder.setXhtmlStrict(xhtmlStrict); builder.setCopyrightNotice(copyrightNotice); builder.setHtmlFilenameFormat(htmlFilenameFormat); if (javadocRelativePath != null || javadocBasePackageName != null) { builder.addLinkUriProcessor( new JavadocShortcutUriProcessor(javadocRelativePath, javadocBasePackageName));
try { documentFooter(); out.endDocument(); if (writer != null) { writer.close(); HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer, formatting); rootBuilder.copyConfiguration(builder); if (item.getLabel() != null) { String title = rootBuilder.getTitle(); if (title == null) { title = item.getLabel(); title += " - " + item.getLabel(); //$NON-NLS-1$ builder.setTitle(title); out.beginDocument(); out.beginHeading(level, attributes);
@Override public void beginBlock(BlockType type, Attributes attributes) { ElementInfo elementInfo = blockTypeToElementInfo.get(type); if (elementInfo == null) { throw new IllegalStateException(type.name()); } writeBlockElements(attributes, elementInfo); blockState.push(elementInfo); if (type == BlockType.TABLE) { applyTableAttributes(attributes); } else if (type == BlockType.TABLE_ROW) { applyTableRowAttributes(attributes); } else if (type == BlockType.TABLE_CELL_HEADER || type == BlockType.TABLE_CELL_NORMAL) { applyCellAttributes(attributes); } else if (type == BlockType.BULLETED_LIST || type == BlockType.NUMERIC_LIST) { applyListAttributes(attributes); } else if (type == BlockType.QUOTE) { applyQuoteAttributes(attributes); } else { applyAttributes(attributes); // create the titled panel effect if a title is specified if (attributes.getTitle() != null) { beginBlock(BlockType.PARAGRAPH, new Attributes()); beginSpan(SpanType.BOLD, new Attributes()); characters(attributes.getTitle()); endSpan(); endBlock(); } } }
File file = new File(item.getFile()); Stylesheet css = new Stylesheet(file); builder.addCssStylesheet(css); builder.setEmitDtd(true); builder.setHtmlDtd( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"); //$NON-NLS-1$ builder.setXhtmlStrict(true);
out.charactersUnescaped("<hr class=\"navigation-separator\"/>"); //$NON-NLS-1$ tableAttributes.setBorder("0"); //$NON-NLS-1$ tableAttributes.setSummary("navigation"); //$NON-NLS-1$ out.beginBlock(BlockType.TABLE, tableAttributes); out.beginBlock(BlockType.TABLE_ROW, new Attributes()); tableCellAttributes.setCssStyle("width: 100%"); //$NON-NLS-1$ tableCellAttributes.setColspan("3"); //$NON-NLS-1$ out.beginBlock(BlockType.TABLE_CELL_HEADER, tableCellAttributes); if (rootPage) { out.characters(rootBuilder.getTitle()); } else { out.characters(current == null ? "" : current.getLabel()); //$NON-NLS-1$ out.endBlock(); out.endBlock(); out.beginBlock(BlockType.TABLE_ROW, new Attributes()); tableCellAttributes.setAlign("left"); //$NON-NLS-1$ tableCellAttributes.setCssStyle("width: 20%"); //$NON-NLS-1$ out.beginBlock(BlockType.TABLE_CELL_NORMAL, tableCellAttributes); if (previous != null) { linkAttributes = new LinkAttributes(); ImageAttributes imageAttributes = new ImageAttributes();
@Override public DocumentBuilder createDocumentBuilder(Writer out, boolean formatting) { return new HtmlDocumentBuilder(out, formatting); }
private void emitEmbeddedTableOfContentsHeader() { if (embeddedTableOfContents) { beginDiv("container"); //$NON-NLS-1$ beginDiv("row"); //$NON-NLS-1$ beginDiv("table-of-contents", "span2"); //$NON-NLS-1$//$NON-NLS-2$ out.beginHeading(1, new Attributes()); out.characters(Messages.getString("SplittingHtmlDocumentBuilder.TableOfContentsHeading")); //$NON-NLS-1$ out.endHeading(); emitEmbeddedTableOfContents(); endDiv(); // table of contents beginDiv("main-content", "span10"); //$NON-NLS-1$//$NON-NLS-2$ } }
void setXhtmlStrict(boolean xhtmlStrict) { delegate.setXhtmlStrict(xhtmlStrict); }
@Override public void acronym(String text, String definition) { out.acronym(text, definition); }
@Override public void beginDocument() { delegate.beginDocument(); }
@Override public void characters(String text) { out.characters(text); }
@Override public void beginHeading(int level, Attributes attributes) { assertCloseImplicitBlock(); emitBlockSeparator(); headingState.push(level); if (headingLevelSupported(level)) { delegate.beginHeading(level, attributes); } else { beginBlock(BlockType.PARAGRAPH, attributes); beginSpan(SpanType.BOLD, new Attributes()); } }
public HtmlSubsetDocumentBuilder(Writer out, boolean formatting) { this(new HtmlDocumentBuilder(checkNotNull(out, "Must provide a writer"), formatting)); //$NON-NLS-1$ }
@Override public void acronym(String text, String definition) { assertOpenBlock(); delegate.acronym(text, definition); }
@Override public void beginDocument() { if (rootBuilder == null || out == null || rootFile == null) { throw new IllegalStateException(); } currentFile = rootFile; out.beginDocument(); documentHeader(); }
@Override public void characters(String text) { assertOpenBlock(); delegate.characters(text); }