private boolean renderLineBreak(String breakText, final String suppressInTag, final Node node, NodeRendererContext context, HtmlWriter html) { if (myLines != null && myNextLine < myLines.size()) { // here we may need to close tags opened since the span tag List<String> openTags = html.getOpenTagsAfterLast("span"); int iMax = openTags.size(); final boolean outputBreakText = iMax == 0 || suppressInTag == null || !suppressInTag.equalsIgnoreCase(openTags.get(iMax - 1)); if (!outputBreakText && !html.isPendingSpace()) { // we add a space for EOL html.raw(" "); } for (int i = iMax; i-- > 0; ) { html.closeTag(openTags.get(i)); } html.tag("/span"); if (outputBreakText) { html.raw(breakText); } outputNextLineBreakSpan(node, html, outputBreakText); for (String tag : openTags) { if (!outputBreakText && context.getHtmlOptions().inlineCodeSpliceClass != null && !context.getHtmlOptions().inlineCodeSpliceClass.isEmpty()) { html.attr(Attribute.CLASS_ATTR, context.getHtmlOptions().inlineCodeSpliceClass).withAttr().tag(tag); } else { html.tag(tag); } } return true; } return false; }
@Override public void render(TextBase node, NodeRendererContext context, HtmlWriter html) { if (myOptions.assignTextAttributes) { final Attributes nodeAttributes = context.extendRenderingNodeAttributes(AttributablePart.NODE, null); if (!nodeAttributes.isEmpty()) { // has attributes then we wrap it in a span html.setAttributes(nodeAttributes).withAttr().tag("span"); context.delegateRender(); html.closeTag("span"); return; } } context.delegateRender(); } }));
html.unIndent().closeTag("div").line(); html.closeTag("div").line(); } else { html.srcPos(node.getChars()) html.attr(Attribute.CLASS_ATTR, "adm-icon").withAttr(ADMONITION_ICON_PART).tag("svg").raw("<use xlink:href=\"#adm-").raw(type).raw("\" />").closeTag("svg"); html.withAttr(ADMONITION_TITLE_PART).tag("span").text(title).closeTag("span").line(); html.closeTag("div").line(); html.unIndent().closeTag("div").line(); html.closeTag("div").line();
@Override public void renderDocument(final NodeRendererContext context, final HtmlWriter html, final Document document, final RenderingPhase phase) { if (phase == BODY_TOP) { // dump out the SVG used by the rest of the nodes HashSet<String> resolvedQualifiers = new HashSet<>(); Set<String> referencedQualifiers = new AdmonitionCollectingVisitor().collectAndGetQualifiers(document); for (String qualifier : referencedQualifiers) { String resolvedQualifier = this.options.qualifierTypeMap.get(qualifier); if (resolvedQualifier == null) resolvedQualifier = options.unresolvedQualifier; resolvedQualifiers.add(resolvedQualifier); } if (!resolvedQualifiers.isEmpty()) { html.line().attr("xmlns","http://www.w3.org/2000/svg").attr(Attribute.CLASS_ATTR, "adm-hidden").withAttr(ADMONITION_SVG_OBJECT_PART) .tag("svg").indent().line(); for (String info : resolvedQualifiers) { String svgContent = options.typeSvgMap.get(info); if (svgContent != null && !svgContent.isEmpty()) { html.raw("<symbol id=\"adm-").raw(info).raw("\">").indent().line() .raw("<svg enable-background=\"new 0 0 24 24\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">") .raw(svgContent).line() .unIndent().raw("</symbol>").line(); } } html.unIndent().closeTag("svg").line(); } } }
private void render(Abbreviation node, NodeRendererContext context, HtmlWriter html) { String text = node.getChars().unescape(); BasedSequence abbreviation = node.getAbbreviation(); String tag; if (options.useLinks) { html.attr("href", "#"); tag = "a"; } else { tag = "abbr"; } html.attr("title", abbreviation); html.srcPos(node.getChars()).withAttr().tag(tag); html.text(text); html.closeTag(tag); }
private boolean renderLineBreak(String breakText, final String suppressInTag, final Node node, NodeRendererContext context, HtmlWriter html) { if (myLines != null && myNextLine < myLines.size()) { // here we may need to close tags opened since the span tag List<String> openTags = html.getOpenTagsAfterLast("span"); int iMax = openTags.size(); final boolean outputBreakText = iMax == 0 || suppressInTag == null || !suppressInTag.equalsIgnoreCase(openTags.get(iMax - 1)); if (!outputBreakText && !html.isPendingSpace()) { // we add a space for EOL html.raw(" "); } for (int i = iMax; i-- > 0; ) { html.closeTag(openTags.get(i)); } html.tag("/span"); if (outputBreakText) { html.raw(breakText); } outputNextLineBreakSpan(node, html, outputBreakText); for (String tag : openTags) { if (!outputBreakText && context.getHtmlOptions().inlineCodeSpliceClass != null && !context.getHtmlOptions().inlineCodeSpliceClass.isEmpty()) { html.attr(Attribute.CLASS_ATTR, context.getHtmlOptions().inlineCodeSpliceClass).withAttr().tag(tag); } else { html.tag(tag); } } return true; } return false; }
@Override public void render(TextBase node, NodeRendererContext context, HtmlWriter html) { if (myOptions.assignTextAttributes) { final Attributes nodeAttributes = context.extendRenderingNodeAttributes(AttributablePart.NODE, null); if (!nodeAttributes.isEmpty()) { // has attributes then we wrap it in a span html.setAttributes(nodeAttributes).withAttr().tag("span"); context.delegateRender(); html.closeTag("span"); return; } } context.delegateRender(); } }));
private void render(Abbreviation node, NodeRendererContext context, HtmlWriter html) { String text = node.getChars().unescape(); BasedSequence abbreviation = node.getAbbreviation(); String tag; if (options.useLinks) { html.attr("href", "#"); tag = "a"; } else { tag = "abbr"; } html.attr("title", abbreviation); html.srcPos(node.getChars()).withAttr().tag(tag); html.text(text); html.closeTag(tag); }