Class AsciiDocCompiler

java.lang.Object
pro.verron.asciidoc.compiler.AsciiDocCompiler

public final class AsciiDocCompiler extends Object
Facade utilities to parse AsciiDoc and compile it to different targets.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Saves the given SVG document as a PNG image file.
    static void
    saveSvgAsImage(String svg, Path path, int dpi, Color background)
    Saves the given SVG document as a PNG image file with specific DPI and background color.
    static String
    toAsciidoc(org.docx4j.openpackaging.packages.WordprocessingMLPackage pkg)
    Compiles a WordprocessingMLPackage into the textual AsciiDoc representation used by tests.
    static String
    toAsciidoc(org.docx4j.openpackaging.packages.WordprocessingMLPackage pkg, boolean skipComments)
    Converts the given WordprocessingMLPackage into its textual AsciiDoc representation.
    static String
    Converts the given AsciiDoc model into its textual AsciiDoc representation.
    static String
    toAsciidoc(AsciiDocModel model, boolean skipComments)
    Converts the given AsciiDoc model into its textual AsciiDoc representation.
    static org.docx4j.openpackaging.packages.WordprocessingMLPackage
    toDocx(String asciidoc)
    Compiles the AsciiDoc source text directly to a WordprocessingMLPackage.
    static org.docx4j.openpackaging.packages.WordprocessingMLPackage
    Compiles the parsed model to a WordprocessingMLPackage.
    static String
    toHtml(String asciidoc)
    Compiles the AsciiDoc source text directly to HTML.
    static String
    Compiles the parsed model to HTML.
    static void
    toImage(String asciidoc, Path path)
    Saves the AsciiDoc source text directly to a PNG image file.
    toModel(String asciidoc)
    Parses AsciiDoc source text into an AsciiDocModel.
    toModel(org.docx4j.openpackaging.packages.WordprocessingMLPackage pkg)
    Parses a Word document into an AsciiDocModel.
    static String
    Reads AsciiDoc source from an input stream and compiles it to SVG.
    static String
    toSvg(String asciidoc)
    Compiles the AsciiDoc source text directly to an SVG document.
    static String
    Compiles the parsed model to an SVG document.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • toDocx

      public static org.docx4j.openpackaging.packages.WordprocessingMLPackage toDocx(String asciidoc)
      Compiles the AsciiDoc source text directly to a WordprocessingMLPackage.
      Parameters:
      asciidoc - source text
      Returns:
      package with rendered content
    • toDocx

      public static org.docx4j.openpackaging.packages.WordprocessingMLPackage toDocx(AsciiDocModel model)
      Compiles the parsed model to a WordprocessingMLPackage.
      Parameters:
      model - parsed model
      Returns:
      package with rendered content
    • toModel

      public static AsciiDocModel toModel(String asciidoc)
      Parses AsciiDoc source text into an AsciiDocModel.
      Parameters:
      asciidoc - source text
      Returns:
      parsed model
    • toSvg

      public static String toSvg(AsciiDocModel model)
      Compiles the parsed model to an SVG document.
      Parameters:
      model - parsed model
      Returns:
      SVG representation
    • toHtml

      public static String toHtml(String asciidoc)
      Compiles the AsciiDoc source text directly to HTML.
      Parameters:
      asciidoc - source text
      Returns:
      HTML representation
    • toHtml

      public static String toHtml(AsciiDocModel model)
      Compiles the parsed model to HTML.
      Parameters:
      model - parsed model
      Returns:
      HTML representation
    • toAsciidoc

      public static String toAsciidoc(org.docx4j.openpackaging.packages.WordprocessingMLPackage pkg)
      Compiles a WordprocessingMLPackage into the textual AsciiDoc representation used by tests. This mirrors the legacy Stringifier output to preserve expectations.
      Parameters:
      pkg - a Word document package
      Returns:
      textual representation
    • toAsciidoc

      public static String toAsciidoc(org.docx4j.openpackaging.packages.WordprocessingMLPackage pkg, boolean skipComments)
      Converts the given WordprocessingMLPackage into its textual AsciiDoc representation.
      Parameters:
      pkg - a Word document package
      skipComments - whether to omit comments from the output
      Returns:
      the textual AsciiDoc representation of the Word document package
    • toModel

      public static AsciiDocModel toModel(org.docx4j.openpackaging.packages.WordprocessingMLPackage pkg)
      Parses a Word document into an AsciiDocModel.
      Parameters:
      pkg - a Word document package
      Returns:
      parsed model
    • toAsciidoc

      public static String toAsciidoc(AsciiDocModel model, boolean skipComments)
      Converts the given AsciiDoc model into its textual AsciiDoc representation.
      Parameters:
      model - the parsed AsciiDoc model to be converted
      skipComments - whether to omit comments from the output
      Returns:
      the textual AsciiDoc representation of the model
    • toAsciidoc

      public static String toAsciidoc(AsciiDocModel model)
      Converts the given AsciiDoc model into its textual AsciiDoc representation.
      Parameters:
      model - the parsed AsciiDoc model to be converted
      Returns:
      the textual AsciiDoc representation of the model
    • toSvg

      public static String toSvg(InputStream input)
      Reads AsciiDoc source from an input stream and compiles it to SVG.
      Parameters:
      input - source stream
      Returns:
      SVG representation
    • toSvg

      public static String toSvg(String asciidoc)
      Compiles the AsciiDoc source text directly to an SVG document.
      Parameters:
      asciidoc - source text
      Returns:
      SVG representation
    • toImage

      public static void toImage(String asciidoc, Path path)
      Saves the AsciiDoc source text directly to a PNG image file.
      Parameters:
      asciidoc - source text
      path - path to save the image
    • saveSvgAsImage

      public static void saveSvgAsImage(String svg, Path path)
      Saves the given SVG document as a PNG image file.
      Parameters:
      svg - SVG source
      path - path to save the image
    • saveSvgAsImage

      public static void saveSvgAsImage(String svg, Path path, int dpi, Color background)
      Saves the given SVG document as a PNG image file with specific DPI and background color.
      Parameters:
      svg - SVG source
      path - path to save the image
      dpi - dots per inch
      background - background color (null for transparent)