@Test public void converts_asciidoc_to_asciidoc() throws IOException { String originalAsciiDoc = IOUtils.toString(getClass().getResourceAsStream("/asciidoc/original/" + asciidocFile), StandardCharsets.UTF_8); String expectedAsciiDoc = IOUtils.toString(getClass().getResourceAsStream("/asciidoc/expected/" + asciidocFile), StandardCharsets.UTF_8); asciidoctor.javaConverterRegistry().register(AsciidocConverter.class, AsciidocConverter.NAME); String result = asciidoctor.convert(originalAsciiDoc, OptionsBuilder.options().backend(AsciidocConverter.NAME).headerFooter(false).asMap()); assertEquals(expectedAsciiDoc, result); }
@Override public String convert(ContentNode node, String transform, Map<Object, Object> opts) { if (null == transform) { transform = node.getNodeName(); } switch (transform) { case "inline_quoted": return convertInlineQuoted((PhraseNode) node); case "paragraph": return convertParagraph((StructuralNode) node); case "inline_anchor": return convertInlineAnchor((PhraseNode) node); case "section": return convertSection((Section) node); case "listing": return convertListing((Block) node); case "literal": return convertLiteral((StructuralNode) node); case "ulist": return convertUList((List) node); case "olist": return convertOList((List) node); case "dlist": return convertDescriptionList((DescriptionList) node); case "admonition": return convertAdmonition((Block) node); case "colist": return convertCoList((List) node); case "embedded": case "document": return convertEmbedded((Document) node); case "example": return convertExample((Block) node); case "floating_title": return convertFloatingTitle((StructuralNode) node); case "image": return convertImage((StructuralNode) node); case "inline_break": return convertInlineBreak(node); case "inline_button": return convertInlineButton(node); case "inline_callout": return convertInlineCallout(node); case "inline_footnote": return convertInlineFootnote(node); case "inline_image": return convertInlineImage((PhraseNode) node); case "inline_indexterm": return convertInlineIndexTerm(node); case "inline_kbd": return convertInlineKbd(node); case "inline_menu": return convertInlineMenu(node); case "open": return convertOpen((StructuralNode) node); case "page_break": return convertPageBreak(node); case "preamble": return convertPreamble((StructuralNode) node); case "quote": return convertQuote((StructuralNode) node); case "sidebar": return convertSidebar((StructuralNode) node); case "stem": return convertStem(node); case "table": return convertTable((Table) node); case "thematic_break": return convertThematicBreak(node); case "verse": return convertVerse((StructuralNode) node); case "video": return convertVideo(node); case "toc": return convertToc(node); case "pass": return convertPass(node); case "audio": return convertAudio(node); case "list": return convertList((List) node); case "list_item": return convertListItem((ListItem) node); default: logger.debug("Don't know how to convert transform: [" + transform + "] Node: " + node); return null; } }
AsciidocConverter extends StringConverter { @Override public String convert(ContentNode node, String transform, Map<Object, Object> opts) { if (null == transform) { transform = node.getNodeName(); } switch (transform) { case "inline_quoted": return convertInlineQuoted((PhraseNode) node); case "paragraph": return convertParagraph((StructuralNode) node); case "inline_anchor": return convertInlineAnchor((PhraseNode) node); case "section": return convertSection((Section) node); case "listing": return convertListing((Block) node); case "literal": return convertLiteral((StructuralNode) node); case "ulist": return convertUList((List) node); case "olist": return convertOList((List) node); case "dlist": return convertDescriptionList((DescriptionList) node); case "admonition": return convertAdmonition((Block) node); case "colist": return convertCoList((List) node); case "embedded": case "document": return convertEmbedded((Document) node); case "example": return convertExample((Block) node); case "floating_title": return convertFloatingTitle((StructuralNode) node); case "image": return convertImage((StructuralNode) node); case "inline_break": return convertInlineBreak(node); case "inline_button": return convertInlineButton(node); case "inline_callout": return convertInlineCallout(node); case "inline_footnote": return convertInlineFootnote(node); case "inline_image": return convertInlineImage((PhraseNode) node); case "inline_indexterm": return convertInlineIndexTerm(node); case "inline_kbd": return convertInlineKbd(node); case "inline_menu": return convertInlineMenu(node); case "open": return convertOpen((StructuralNode) node); case "page_break": return convertPageBreak(node); case "preamble": return convertPreamble((StructuralNode) node); case "quote": return convertQuote((StructuralNode) node); case "sidebar": return convertSidebar((StructuralNode) node); case "stem": return convertStem(node); case "table": return convertTable((Table) node); case "thematic_break": return convertThematicBreak(node); case "verse": return convertVerse((StructuralNode) node); case "video": return convertVideo(node); case "toc": return convertToc(node); case "pass": return convertPass(node); case "audio": return convertAudio(node); case "list": return convertList((List) node); case "list_item": return convertListItem((ListItem) node); default: logger.debug("Don't know how to convert transform: [" + transform + "] Node: " + node); return null; } } }
AsciidocConverter extends StringConverter { @Override public String convert(ContentNode node, String transform, Map<Object, Object> opts) { if (null == transform) { transform = node.getNodeName(); } switch (transform) { case "inline_quoted": return convertInlineQuoted((PhraseNode) node); case "paragraph": return convertParagraph((StructuralNode) node); case "inline_anchor": return convertInlineAnchor((PhraseNode) node); case "section": return convertSection((Section) node); case "listing": return convertListing((Block) node); case "literal": return convertLiteral((StructuralNode) node); case "ulist": return convertUList((List) node); case "olist": return convertOList((List) node); case "dlist": return convertDescriptionList((DescriptionList) node); case "admonition": return convertAdmonition((Block) node); case "colist": return convertCoList((List) node); case "embedded": case "document": return convertEmbedded((Document) node); case "example": return convertExample((Block) node); case "floating_title": return convertFloatingTitle((StructuralNode) node); case "image": return convertImage((StructuralNode) node); case "inline_break": return convertInlineBreak(node); case "inline_button": return convertInlineButton(node); case "inline_callout": return convertInlineCallout(node); case "inline_footnote": return convertInlineFootnote(node); case "inline_image": return convertInlineImage((PhraseNode) node); case "inline_indexterm": return convertInlineIndexTerm(node); case "inline_kbd": return convertInlineKbd(node); case "inline_menu": return convertInlineMenu(node); case "open": return convertOpen((StructuralNode) node); case "page_break": return convertPageBreak(node); case "preamble": return convertPreamble((StructuralNode) node); case "quote": return convertQuote((StructuralNode) node); case "sidebar": return convertSidebar((StructuralNode) node); case "stem": return convertStem(node); case "table": return convertTable((Table) node); case "thematic_break": return convertThematicBreak(node); case "verse": return convertVerse((StructuralNode) node); case "video": return convertVideo(node); case "toc": return convertToc(node); case "pass": return convertPass(node); case "audio": return convertAudio(node); case "list": return convertList((List) node); case "list_item": return convertListItem((ListItem) node); default: logger.debug("Don't know how to convert transform: [" + transform + "] Node: " + node); return null; } } AsciidocConverter(String backend, Map<String, Object> opts); }
AsciidocConverter extends StringConverter { @Override public String convert(ContentNode node, String transform, Map<Object, Object> opts) { if (null == transform) { transform = node.getNodeName(); } switch (transform) { case "inline_quoted": return convertInlineQuoted((PhraseNode) node); case "paragraph": return convertParagraph((StructuralNode) node); case "inline_anchor": return convertInlineAnchor((PhraseNode) node); case "section": return convertSection((Section) node); case "listing": return convertListing((Block) node); case "literal": return convertLiteral((StructuralNode) node); case "ulist": return convertUList((List) node); case "olist": return convertOList((List) node); case "dlist": return convertDescriptionList((DescriptionList) node); case "admonition": return convertAdmonition((Block) node); case "colist": return convertCoList((List) node); case "embedded": case "document": return convertEmbedded((Document) node); case "example": return convertExample((Block) node); case "floating_title": return convertFloatingTitle((StructuralNode) node); case "image": return convertImage((StructuralNode) node); case "inline_break": return convertInlineBreak(node); case "inline_button": return convertInlineButton(node); case "inline_callout": return convertInlineCallout(node); case "inline_footnote": return convertInlineFootnote(node); case "inline_image": return convertInlineImage((PhraseNode) node); case "inline_indexterm": return convertInlineIndexTerm(node); case "inline_kbd": return convertInlineKbd(node); case "inline_menu": return convertInlineMenu(node); case "open": return convertOpen((StructuralNode) node); case "page_break": return convertPageBreak(node); case "preamble": return convertPreamble((StructuralNode) node); case "quote": return convertQuote((StructuralNode) node); case "sidebar": return convertSidebar((StructuralNode) node); case "stem": return convertStem(node); case "table": return convertTable((Table) node); case "thematic_break": return convertThematicBreak(node); case "verse": return convertVerse((StructuralNode) node); case "video": return convertVideo(node); case "toc": return convertToc(node); case "pass": return convertPass(node); case "audio": return convertAudio(node); case "list": return convertList((List) node); case "list_item": return convertListItem((ListItem) node); default: logger.debug("Don't know how to convert transform: [" + transform + "] Node: " + node); return null; } } AsciidocConverter(String backend, Map<String, Object> opts); @Override String convert(ContentNode node, String transform, Map<Object, Object> opts); }
AsciidocConverter extends StringConverter { @Override public String convert(ContentNode node, String transform, Map<Object, Object> opts) { if (null == transform) { transform = node.getNodeName(); } switch (transform) { case "inline_quoted": return convertInlineQuoted((PhraseNode) node); case "paragraph": return convertParagraph((StructuralNode) node); case "inline_anchor": return convertInlineAnchor((PhraseNode) node); case "section": return convertSection((Section) node); case "listing": return convertListing((Block) node); case "literal": return convertLiteral((StructuralNode) node); case "ulist": return convertUList((List) node); case "olist": return convertOList((List) node); case "dlist": return convertDescriptionList((DescriptionList) node); case "admonition": return convertAdmonition((Block) node); case "colist": return convertCoList((List) node); case "embedded": case "document": return convertEmbedded((Document) node); case "example": return convertExample((Block) node); case "floating_title": return convertFloatingTitle((StructuralNode) node); case "image": return convertImage((StructuralNode) node); case "inline_break": return convertInlineBreak(node); case "inline_button": return convertInlineButton(node); case "inline_callout": return convertInlineCallout(node); case "inline_footnote": return convertInlineFootnote(node); case "inline_image": return convertInlineImage((PhraseNode) node); case "inline_indexterm": return convertInlineIndexTerm(node); case "inline_kbd": return convertInlineKbd(node); case "inline_menu": return convertInlineMenu(node); case "open": return convertOpen((StructuralNode) node); case "page_break": return convertPageBreak(node); case "preamble": return convertPreamble((StructuralNode) node); case "quote": return convertQuote((StructuralNode) node); case "sidebar": return convertSidebar((StructuralNode) node); case "stem": return convertStem(node); case "table": return convertTable((Table) node); case "thematic_break": return convertThematicBreak(node); case "verse": return convertVerse((StructuralNode) node); case "video": return convertVideo(node); case "toc": return convertToc(node); case "pass": return convertPass(node); case "audio": return convertAudio(node); case "list": return convertList((List) node); case "list_item": return convertListItem((ListItem) node); default: logger.debug("Don't know how to convert transform: [" + transform + "] Node: " + node); return null; } } AsciidocConverter(String backend, Map<String, Object> opts); @Override String convert(ContentNode node, String transform, Map<Object, Object> opts); static final String NAME; }