@SuppressWarnings("WeakerAccess") public static void renderLooseParagraph(final Paragraph node, final NodeFormatterContext context, final MarkdownWriter markdown) { markdown.blankLine(); renderTextBlockParagraphLines(node, context, markdown); markdown.tailBlankLine(); }
@Override public void renderReferenceBlock(final FootnoteBlock node, final NodeFormatterContext context, final MarkdownWriter markdown) { markdown.blankLine().append("[^"); markdown.append(transformReferenceId(node.getText().toString(), context)); markdown.append("]: "); markdown.pushPrefix().addPrefix(" "); context.renderChildren(node); markdown.popPrefix(); markdown.blankLine(); }
private void render(BlankLine node, NodeFormatterContext context, MarkdownWriter markdown) { if (context.getDocument().get(LIST_ITEM_SPACING) == null) { if (!(node.getPrevious() == null || node.getPrevious() instanceof BlankLine)) { blankLines = 0; } blankLines++; if (blankLines <= formatterOptions.maxBlankLines) markdown.blankLine(blankLines); } }
private void render(ThematicBreak node, NodeFormatterContext context, MarkdownWriter markdown) { markdown.blankLine(); if (formatterOptions.thematicBreak != null) { markdown.append(formatterOptions.thematicBreak); } else { markdown.append(node.getChars()); } markdown.tailBlankLine(); }
@Override public void renderReferenceBlock(final EnumeratedReferenceBlock node, final NodeFormatterContext context, final MarkdownWriter markdown) { markdown.blankLine().append("[@").appendNonTranslating(node.getText()).append("]: "); markdown.pushPrefix().addPrefix(" "); context.renderChildren(node); markdown.popPrefix(); markdown.blankLine(); }
@Override public void renderReferenceBlock(final MacroDefinitionBlock node, final NodeFormatterContext context, final MarkdownWriter markdown) { markdown.blankLine().append(">>>").append(transformReferenceId(node.getName().toString(), context)).line(); Node child = node.getFirstChild(); if (child instanceof Paragraph && child == node.getLastChild()) { // if a single paragraph then we unwrap it and output only its children as inline text context.renderChildren(child); } else { context.renderChildren(node); } markdown.line().append("<<<").blankLine(); }
protected void renderReference(B node, NodeFormatterContext context, MarkdownWriter markdown) { if (!repositoryNodesDone) { switch (getTranslationReferencePlacement()) { case AS_IS: renderReferenceBlock(node, context, markdown); if (node.getNext() == null || node.getNext().getClass() != node.getClass()) { markdown.blankLine(); } break; case GROUP_WITH_FIRST: // must be the first since we are here formatReferences(context, markdown); break; case GROUP_WITH_LAST: if (node == lastReference) { formatReferences(context, markdown); } break; } } } }
@Override public void renderDocument(final NodeFormatterContext context, final MarkdownWriter markdown, final Document document, final FormattingPhase phase) { if (phase == FormattingPhase.DOCUMENT_FIRST) { final Node node = document.getFirstChild(); if (node instanceof JekyllFrontMatterBlock) { markdown.openPreFormatted(false); markdown.append(node.getChars()).blankLine(); markdown.closePreFormatted(); } } }
@Override public void renderDocument(final NodeFormatterContext context, final MarkdownWriter markdown, final Document document, final FormattingPhase phase) { if (phase == FormattingPhase.DOCUMENT_FIRST) { final Node node = document.getFirstChild(); if (node instanceof YamlFrontMatterBlock) { markdown.openPreFormatted(false); markdown.append(node.getChars()).blankLine(); markdown.closePreFormatted(); } } }
public MarkdownWriter tailBlankLine(int count) { Node node = context.getCurrentNode(); if (isLastBlockQuoteChild(node)) { if (getPushedPrefixCount() > 0) { flush(-1); // clear pending lines so pop prefix is not delayed, if PREFIX_AFTER_PENDING_EOL is enabled popPrefix(); pushPrefix(); } } blankLine(count); return this; }
private String renderInSubContext(TranslatingSpanRender render, boolean copyToMain) { StringBuilder span = new StringBuilder(); MarkdownWriter savedMarkdown = myWriter; final NodeFormatterContext subContext = myWriter.getContext().getSubContext(span); final MarkdownWriter writer = subContext.getMarkdown(); myWriter = writer; render.render(subContext, writer); int pendingEOL = writer.getPendingEOL(); writer.flush(-1); String spanText = writer.getText(); myWriter = savedMarkdown; if (copyToMain) { myWriter.append(spanText); if (pendingEOL == 1) { myWriter.line(); } else { myWriter.blankLine(pendingEOL - 1); } } return spanText; }
public static void renderList(final ListBlock node, final NodeFormatterContext context, MarkdownWriter markdown, List<Node> itemList) { if (context.getFormatterOptions().listAddBlankLineBefore && !node.isOrDescendantOfType(ListItem.class)) { markdown.blankLine(); if (itemSpacing == ListSpacing.LOOSE && (listSpacing == null || listSpacing == ListSpacing.LOOSE)) markdown.blankLine(); context.render(item); markdown.blankLine();
private void render(HtmlBlock node, NodeFormatterContext context, MarkdownWriter markdown) { if (node.hasChildren()) { // inner blocks handle rendering context.renderChildren(node); } else { markdown.blankLine(); // TODO: this really needs to be parsed but we won't do it switch (context.getRenderPurpose()) { case TRANSLATION_SPANS: case TRANSLATED_SPANS: markdown.appendNonTranslating(myHtmlBlockPrefix, node.getChars().trimEOL(), ">", node.getChars().trimmedEOL()); break; case TRANSLATED: markdown.openPreFormatted(true); markdown.appendNonTranslating(node.getChars()); markdown.closePreFormatted(); break; case FORMAT: default: markdown.append(node.getChars()); } markdown.blankLine(); } }
private void render(final AdmonitionBlock node, final NodeFormatterContext context, MarkdownWriter markdown) { markdown.blankLine(); markdown.append(node.getOpeningMarker()).append(' '); markdown.appendNonTranslating(node.getInfo()); if (node.getTitle().isNotNull()) { markdown.append(' ').append('"').appendTranslating(node.getTitle()).append('"'); } markdown.line(); markdown.pushPrefix().addPrefix(RepeatedCharSequence.of(" ", options.contentIndent).toString()); context.renderChildren(node); markdown.blankLine(); markdown.popPrefix(); }
final boolean endWrappingDisabled = ((ParagraphContainer) node.getParent()).isParagraphEndWrappingDisabled(node); if (startWrappingDisabled || endWrappingDisabled) { if (!startWrappingDisabled) markdown.blankLine(); renderTextBlockParagraphLines(node, context, markdown); if (!endWrappingDisabled) markdown.blankLine(); } else { renderLooseParagraph(node, context, markdown);
private void render(final DefinitionItem node, final NodeFormatterContext context, final MarkdownWriter markdown) { BasedSequence openMarkerChars = node.getChars().prefixOf(node.getFirstChild().getChars()); BasedSequence openMarker = openMarkerChars.subSequence(0,1); BasedSequence openMarkerSpaces = openMarkerChars.subSequence(1); if (options.markerSpaces >= 1 && openMarkerSpaces.length() != options.markerSpaces) { openMarkerSpaces = SubSequence.of(RepeatedCharSequence.of(' ', options.markerSpaces)); } switch (options.markerType) { case ANY: break; case COLON: openMarker = SubSequence.of(":"); break; case TILDE: openMarker = SubSequence.of("~"); break; } markdown.line().append(openMarker).append(openMarkerSpaces); markdown.pushPrefix().addPrefix(RepeatedCharSequence.of(' ', context.getFormatterOptions().itemContentIndent ? openMarker.length() + openMarkerSpaces.length() : listOptions.getItemIndent())); context.renderChildren(node); markdown.popPrefix(); if (!context.getOptions().get(BLANK_LINES_IN_AST)) { // add blank lines after last paragraph item Node child = node.getLastChild(); if (child instanceof Paragraph && ((Paragraph) child).isTrailingBlankLine()) { markdown.blankLine(); } } }
private void render(final Heading node, final NodeFormatterContext context, final MarkdownWriter markdown) { markdown.blankLine(); if (node.isAtxHeading()) { markdown.append(node.getOpeningMarker());