@SuppressWarnings("WeakerAccess") public static void renderTextBlockParagraphLines(final Node node, final NodeFormatterContext context, final MarkdownWriter markdown) { context.translatingSpan(new TranslatingSpanRender() { @Override public void render(final NodeFormatterContext context, final MarkdownWriter writer) { context.renderChildren(node); } }); markdown.line(); }
public void flush(int maxBlankLines) { markdown.line().flush(maxBlankLines); } }
public void flush() { markdown.line().flush(); }
private void render(final TableRow node, final NodeFormatterContext context, MarkdownWriter markdown) { context.renderChildren(node); if (context.getRenderPurpose() == FORMAT) { if (!myTable.isSeparator()) myTable.nextRow(); } else { markdown.line(); } }
@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(); }
@Override public void renderReferenceBlock(final AbbreviationBlock node, final NodeFormatterContext context, final MarkdownWriter markdown) { markdown.append(node.getOpeningMarker()).append(transformReferenceId(node.getText().toString(), context)).append(node.getClosingMarker()).append(' '); markdown.appendTranslating(node.getAbbreviation()).line(); }
private void render(final TableCaption node, final NodeFormatterContext context, MarkdownWriter markdown) { if (context.getRenderPurpose() == FORMAT) { myTable.setCaptionWithMarkers(node.getOpeningMarker(), node.getText(), node.getClosingMarker()); } else { // KLUDGE: to reuse the table formatting logic of MarkdownTable String dummyCaption = node.hasChildren() ? "dummy" : ""; String formattedCaption = MarkdownTable.formattedCaption(BasedSequenceImpl.of(dummyCaption), options); if (formattedCaption != null) { markdown.line().append(node.getOpeningMarker()); context.renderChildren(node); markdown.append(node.getClosingMarker()).line(); } } }
Map<Integer, Integer> offsets = myTable.getTrackedOffsets(); if (offsets.size() > 0) { markdown.append("\nTracked Offsets").line(); // simulate flex example ast dump String sep = " "; int i = 0;
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; }
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(); }
@SuppressWarnings("WeakerAccess") public static void renderTextBlockParagraphLines(final Node node, final NodeFormatterContext context, final MarkdownWriter markdown) { context.translatingSpan(new TranslatingSpanRender() { @Override public void render(final NodeFormatterContext context, final MarkdownWriter writer) { context.renderChildren(node); } }); markdown.line(); }
public void flush(int maxBlankLines) { markdown.line().flush(maxBlankLines); } }
@Override public void renderReferenceBlock(final Reference node, final NodeFormatterContext context, final MarkdownWriter markdown) { if (context.isTransformingText()) { markdown.append(node.getOpeningMarker()); markdown.appendTranslating(node.getReference()); markdown.append(node.getClosingMarker()); markdown.append(' '); markdown.append(node.getUrlOpeningMarker()); markdown.appendNonTranslating(node.getPageRef()); markdown.append(node.getAnchorMarker()); if (node.getAnchorRef().isNotNull()) { CharSequence anchorRef = context.transformAnchorRef(node.getPageRef(), node.getAnchorRef()); markdown.append(anchorRef); } markdown.append(node.getUrlClosingMarker()); if (node.getTitleOpeningMarker().isNotNull()) { markdown.append(' '); markdown.append(node.getTitleOpeningMarker()); if (node.getTitle().isNotNull()) markdown.appendTranslating(node.getTitle()); markdown.append(node.getTitleClosingMarker()); } markdown.append(node.getUrlClosingMarker()).line(); } else { markdown.append(node.getChars()).line(); } }
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 TableRow node, final NodeFormatterContext context, MarkdownWriter markdown) { context.renderChildren(node); if (context.getRenderPurpose() == FORMAT) { if (!myTable.isSeparator()) myTable.nextRow(); } else { markdown.line(); } }
markdown.line();
private void render(final TableCaption node, final NodeFormatterContext context, MarkdownWriter markdown) { if (context.getRenderPurpose() == FORMAT) { myTable.setCaptionWithMarkers(node.getOpeningMarker(), node.getText(), node.getClosingMarker()); } else { // KLUDGE: to reuse the table formatting logic of MarkdownTable String dummyCaption = node.hasChildren() ? "dummy" : ""; String formattedCaption = MarkdownTable.formattedCaption(BasedSequenceImpl.of(dummyCaption), options); if (formattedCaption != null) { markdown.line().append(node.getOpeningMarker()); context.renderChildren(node); markdown.append(node.getClosingMarker()).line(); } } }
@Override public void renderReferenceBlock(final AbbreviationBlock node, final NodeFormatterContext context, final MarkdownWriter markdown) { markdown.append(node.getOpeningMarker()).append(transformReferenceId(node.getText().toString(), context)).append(node.getClosingMarker()).append(' '); markdown.appendTranslating(node.getAbbreviation()).line(); }