Class JRubyAsciidoctor

java.lang.Object
org.asciidoctor.jruby.internal.JRubyAsciidoctor
All Implemented Interfaces:
AutoCloseable, Asciidoctor, AsciidoctorJRuby, LogHandler

public class JRubyAsciidoctor extends Object implements AsciidoctorJRuby, LogHandler
  • Field Details

    • rubyGemsPreloader

      protected RubyGemsPreloader rubyGemsPreloader
    • rubyRuntime

      protected org.jruby.Ruby rubyRuntime
  • Constructor Details

    • JRubyAsciidoctor

      public JRubyAsciidoctor()
  • Method Details

    • create

      public static JRubyAsciidoctor create()
    • create

      public static JRubyAsciidoctor create(String gemPath)
    • create

      public static JRubyAsciidoctor create(List<String> loadPaths)
    • create

      public static JRubyAsciidoctor create(ClassLoader classloader)
    • create

      public static JRubyAsciidoctor create(ClassLoader classloader, String gemPath)
    • create

      public static JRubyAsciidoctor create(List<String> loadPaths, String gemPath)
    • close

      public void close()
      Specified by:
      close in interface Asciidoctor
      Specified by:
      close in interface AutoCloseable
    • registerLogHandler

      public void registerLogHandler(LogHandler logHandler)
      Description copied from interface: Asciidoctor
      Register a LogHandler to capture Asciidoctor message records.
      Specified by:
      registerLogHandler in interface Asciidoctor
      Parameters:
      logHandler - handler instance.
    • unregisterLogHandler

      public void unregisterLogHandler(LogHandler logHandler)
      Description copied from interface: Asciidoctor
      Unregister a LogHandler.
      Specified by:
      unregisterLogHandler in interface Asciidoctor
      Parameters:
      logHandler - handler instance.
    • getRubyRuntime

      public org.jruby.Ruby getRubyRuntime()
    • readDocumentHeader

      public DocumentHeader readDocumentHeader(File file)
      Description copied from interface: Asciidoctor
      Reads only header parameters instead of all document.
      Specified by:
      readDocumentHeader in interface Asciidoctor
      Parameters:
      file - to read the attributes.
      Returns:
      header.
    • readDocumentHeader

      public DocumentHeader readDocumentHeader(String content)
      Description copied from interface: Asciidoctor
      Reads only header parameters instead of all document.
      Specified by:
      readDocumentHeader in interface Asciidoctor
      Parameters:
      content - where converted content is written. Writer is flushed, but not closed.
      Returns:
      header.
    • readDocumentHeader

      public DocumentHeader readDocumentHeader(Reader contentReader)
      Description copied from interface: Asciidoctor
      Reads only header parameters instead of all document.
      Specified by:
      readDocumentHeader in interface Asciidoctor
      Parameters:
      contentReader - where asciidoc content is read.
      Returns:
      header.
    • requireLibrary

      public void requireLibrary(String... library)
      Description copied from interface: Asciidoctor
      Loads the given Ruby gem(s) by name.
      Specified by:
      requireLibrary in interface Asciidoctor
    • requireLibraries

      public void requireLibraries(Collection<String> libraries)
      Description copied from interface: Asciidoctor
      Loads the given Ruby gem in requiredLibraries by name.
      Specified by:
      requireLibraries in interface Asciidoctor
    • javaExtensionRegistry

      public JavaExtensionRegistry javaExtensionRegistry()
      Description copied from interface: Asciidoctor
      Creates an extension registry ready to be used for registering Java extensions.
      Specified by:
      javaExtensionRegistry in interface Asciidoctor
      Returns:
      Extension Registry object.
    • rubyExtensionRegistry

      public RubyExtensionRegistry rubyExtensionRegistry()
      Description copied from interface: Asciidoctor
      Creates an Ruby extension registry ready to be used for registering Ruby extension.
      Specified by:
      rubyExtensionRegistry in interface Asciidoctor
      Returns:
      Extension Registry object.
    • javaConverterRegistry

      public JavaConverterRegistry javaConverterRegistry()
      Description copied from interface: Asciidoctor
      Creates a registry for registering Java converters.
      Specified by:
      javaConverterRegistry in interface Asciidoctor
      Returns:
      Converter Registry object.
    • syntaxHighlighterRegistry

      public SyntaxHighlighterRegistry syntaxHighlighterRegistry()
      Description copied from interface: Asciidoctor
      Creates a registry for registering Java syntax highlighter.

      This API is experimental and might change in an incompatible way in a minor version update!

      Specified by:
      syntaxHighlighterRegistry in interface Asciidoctor
      Returns:
      Converter Registry object.
    • unregisterAllExtensions

      public void unregisterAllExtensions()
      Description copied from interface: Asciidoctor
      Unregister all registered extensions.
      Specified by:
      unregisterAllExtensions in interface Asciidoctor
    • shutdown

      public void shutdown()
      Description copied from interface: Asciidoctor
      This method frees all resources consumed by AsciidoctorJ module. Keep in mind that if this method is called, instance becomes unusable and you should create another instance.
      Specified by:
      shutdown in interface Asciidoctor
    • asciidoctorVersion

      public String asciidoctorVersion()
      Description copied from interface: Asciidoctor
      Method that gets the asciidoctor version which is being used..
      Specified by:
      asciidoctorVersion in interface Asciidoctor
      Returns:
      Version number.
    • convert

      public String convert(String content, Map<String,Object> options)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as String object.

      Specified by:
      convert in interface Asciidoctor
      Parameters:
      content - the AsciiDoc source as String.
      options - a Map of options to control processing (default: {}).
      Returns:
      the rendered output String is returned
    • convert

      public <T> T convert(String content, Map<String,Object> options, Class<T> expectedResult)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as String object.

      Specified by:
      convert in interface Asciidoctor
      Parameters:
      content - the AsciiDoc source as String.
      options - a Map of options to control processing (default: {}).
      expectedResult - the expected return type. Usually String for HTML based formats. In this case Asciidoctor.convert(String, Map) is the same.
      Returns:
      the rendered output String is returned
    • convert

      public String convert(String content, Options options)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as String object.

      Specified by:
      convert in interface Asciidoctor
      Parameters:
      content - the AsciiDoc source as String.
      options - options to control processing (default: empty).
      Returns:
      the rendered output String is returned
    • convert

      public <T> T convert(String content, Options options, Class<T> expectedResult)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as String object.

      Specified by:
      convert in interface Asciidoctor
      Parameters:
      content - the AsciiDoc source as String.
      options - options to control processing (default: empty).
      expectedResult - the expected return type. Usually String for HTML based formats. In this case Asciidoctor.convert(String, Options) is the same.
      Returns:
      the rendered output String is returned
    • convert

      public String convert(String content, OptionsBuilder options)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as String object.

      Specified by:
      convert in interface Asciidoctor
      Parameters:
      content - the AsciiDoc source as String.
      options - a Map of options to control processing (default: {}).
      Returns:
      the rendered output String is returned
    • convert

      public <T> T convert(String content, OptionsBuilder options, Class<T> expectedResult)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as String object.

      Specified by:
      convert in interface Asciidoctor
      Parameters:
      content - the AsciiDoc source as String.
      options - a Map of options to control processing (default: {}).
      expectedResult - the expected return type. Usually String for HTML based formats. In this case Asciidoctor.convert(String, OptionsBuilder) is the same.
      Returns:
      the rendered output String is returned
    • convert

      public void convert(Reader contentReader, Writer rendererWriter, Map<String,Object> options) throws IOException
      Description copied from interface: Asciidoctor
      Parse the document read from reader sending the converted result to writer.
      Specified by:
      convert in interface Asciidoctor
      Parameters:
      contentReader - where asciidoc content is read.
      rendererWriter - where rendered content is written. Writer is flushed, but not closed.
      options - a Map of options to control processing (default: {}).
      Throws:
      IOException - if an error occurs while writing rendered content, this exception is thrown.
    • convert

      public void convert(Reader contentReader, Writer rendererWriter, Options options) throws IOException
      Description copied from interface: Asciidoctor
      Parse the document read from reader sending the converted result to writer.
      Specified by:
      convert in interface Asciidoctor
      Parameters:
      contentReader - where asciidoc content is read.
      rendererWriter - where rendered content is written. Writer is flushed, but not closed.
      options - options to control processing (default: empty).
      Throws:
      IOException - if an error occurs while writing rendered content, this exception is thrown.
    • convert

      public void convert(Reader contentReader, Writer rendererWriter, OptionsBuilder options) throws IOException
      Description copied from interface: Asciidoctor
      Parse the document read from reader sending the converted result to writer.
      Specified by:
      convert in interface Asciidoctor
      Parameters:
      contentReader - where asciidoc content is read.
      rendererWriter - where rendered content is written. Writer is flushed, but not closed.
      options - a Map of options to control processing (default: {}).
      Throws:
      IOException - if an error occurs while writing rendered content, this exception is thrown.
    • convertFile

      public String convertFile(File file, Map<String,Object> options)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as File.

      If the :in_place option is true, and the input is a File, the output is written to a file adjacent to the input file, having an extension that corresponds to the backend format. Otherwise, if the :to_file option is specified, the file is written to that file. If :to_file is not an absolute path, it is resolved relative to :to_dir, if given, otherwise the Document#base_dir. If the target directory does not exist, it will not be created unless the :mkdirs option is set to true. If the file cannot be written because the target directory does not exist, or because it falls outside of the Document#base_dir in safe mode, an IOError is raised.

      Specified by:
      convertFile in interface Asciidoctor
      Parameters:
      file - an input Asciidoctor file.
      options - a Map of options to control processing (default: {}).
      Returns:
      returns nothing if the rendered output String is written to a file.
    • convertFile

      public <T> T convertFile(File file, Map<String,Object> options, Class<T> expectedResult)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as File.

      If the :in_place option is true, and the input is a File, the output is written to a file adjacent to the input file, having an extension that corresponds to the backend format. Otherwise, if the :to_file option is specified, the file is written to that file. If :to_file is not an absolute path, it is resolved relative to :to_dir, if given, otherwise the Document#base_dir. If the target directory does not exist, it will not be created unless the :mkdirs option is set to true. If the file cannot be written because the target directory does not exist, or because it falls outside of the Document#base_dir in safe mode, an IOError is raised.

      Specified by:
      convertFile in interface Asciidoctor
      Parameters:
      file - an input Asciidoctor file.
      options - a Map of options to control processing (default: {}).
      expectedResult - the expected return type. Usually String for HTML based formats. In this case Asciidoctor.convertFile(File, Map) is the same.
      Returns:
      returns nothing if the rendered output is written to a file.
    • convertFile

      public String convertFile(File file, Options options)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as File.

      If the :in_place option is true, and the input is a File, the output is written to a file adjacent to the input file, having an extension that corresponds to the backend format. Otherwise, if the :to_file option is specified, the file is written to that file. If :to_file is not an absolute path, it is resolved relative to :to_dir, if given, otherwise the Document#base_dir. If the target directory does not exist, it will not be created unless the :mkdirs option is set to true. If the file cannot be written because the target directory does not exist, or because it falls outside of the Document#base_dir in safe mode, an IOError is raised.

      Specified by:
      convertFile in interface Asciidoctor
      Parameters:
      file - an input Asciidoctor file.
      options - options to control processing (default: empty).
      Returns:
      returns nothing if the rendered output String is written to a file.
    • convertFile

      public <T> T convertFile(File file, Options options, Class<T> expectedResult)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as File.

      If the :in_place option is true, and the input is a File, the output is written to a file adjacent to the input file, having an extension that corresponds to the backend format. Otherwise, if the :to_file option is specified, the file is written to that file. If :to_file is not an absolute path, it is resolved relative to :to_dir, if given, otherwise the Document#base_dir. If the target directory does not exist, it will not be created unless the :mkdirs option is set to true. If the file cannot be written because the target directory does not exist, or because it falls outside of the Document#base_dir in safe mode, an IOError is raised.

      Specified by:
      convertFile in interface Asciidoctor
      Parameters:
      file - an input Asciidoctor file.
      options - options to control processing (default: empty).
      expectedResult - the expected return type. Usually String for HTML based formats. In this case Asciidoctor.convertFile(File, Map) is the same.
      Returns:
      returns nothing if the rendered output is written to a file.
    • convertFile

      public String convertFile(File file, OptionsBuilder options)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as File.

      If the :in_place option is true, and the input is a File, the output is written to a file adjacent to the input file, having an extension that corresponds to the backend format. Otherwise, if the :to_file option is specified, the file is written to that file. If :to_file is not an absolute path, it is resolved relative to :to_dir, if given, otherwise the Document#base_dir. If the target directory does not exist, it will not be created unless the :mkdirs option is set to true. If the file cannot be written because the target directory does not exist, or because it falls outside of the Document#base_dir in safe mode, an IOError is raised.

      Specified by:
      convertFile in interface Asciidoctor
      Parameters:
      file - an input Asciidoctor file.
      options - a Map of options to control processing (default: {}).
      Returns:
      returns nothing if the rendered output String is written to a file.
    • convertFile

      public <T> T convertFile(File file, OptionsBuilder options, Class<T> expectedResult)
      Description copied from interface: Asciidoctor
      Parse the AsciiDoc source input into an Document Document and convert it to the specified backend format.

      Accepts input as File.

      If the :in_place option is true, and the input is a File, the output is written to a file adjacent to the input file, having an extension that corresponds to the backend format. Otherwise, if the :to_file option is specified, the file is written to that file. If :to_file is not an absolute path, it is resolved relative to :to_dir, if given, otherwise the Document#base_dir. If the target directory does not exist, it will not be created unless the :mkdirs option is set to true. If the file cannot be written because the target directory does not exist, or because it falls outside of the Document#base_dir in safe mode, an IOError is raised.

      Specified by:
      convertFile in interface Asciidoctor
      Parameters:
      file - an input Asciidoctor file.
      options - a Map of options to control processing (default: {}).
      expectedResult - the expected return type. Usually String for HTML based formats. In this case Asciidoctor.convertFile(File, Map) is the same.
      Returns:
      returns nothing if the rendered output is written to a file.
    • convertDirectory

      public String[] convertDirectory(Iterable<File> directoryWalker, Map<String,Object> options)
      Description copied from interface: Asciidoctor
      Convert all AsciiDoc files found in directoryWalker. See AsciiDocDirectoryWalker for reference strategy.
      Specified by:
      convertDirectory in interface Asciidoctor
      Parameters:
      directoryWalker - strategy used to retrieve all files to be rendered.
      options - a Map of options to control processing (default: {}).
      Returns:
      returns an array of 0 positions if the rendered output is written to a file.
    • convertDirectory

      public String[] convertDirectory(Iterable<File> directoryWalker, Options options)
      Description copied from interface: Asciidoctor
      Convert all AsciiDoc files found in directoryWalker. See AsciiDocDirectoryWalker for reference strategy.
      Specified by:
      convertDirectory in interface Asciidoctor
      Parameters:
      directoryWalker - strategy used to retrieve all files to be rendered.
      options - options to control processing (default: empty).
      Returns:
      returns an array of 0 positions if the rendered output is written to a file.
    • convertDirectory

      public String[] convertDirectory(Iterable<File> directoryWalker, OptionsBuilder options)
      Description copied from interface: Asciidoctor
      Convert all AsciiDoc files found in directoryWalker. See AsciiDocDirectoryWalker for reference strategy.
      Specified by:
      convertDirectory in interface Asciidoctor
      Parameters:
      directoryWalker - strategy used to retrieve all files to be rendered.
      options - a Map of options to control processing (default: {}).
      Returns:
      returns an array of 0 positions if the rendered output is written to a file.
    • convertFiles

      public String[] convertFiles(Collection<File> files, Map<String,Object> options)
      Description copied from interface: Asciidoctor
      Convert all files from a collection.
      Specified by:
      convertFiles in interface Asciidoctor
      Parameters:
      files - to be converted.
      options - a Map of options to control processing (default: {}).
      Returns:
      returns an array of 0 positions if the rendered output is written to a file.
    • convertFiles

      public String[] convertFiles(Collection<File> asciidoctorFiles, Options options)
      Description copied from interface: Asciidoctor
      Convert all files from a collection.
      Specified by:
      convertFiles in interface Asciidoctor
      Parameters:
      asciidoctorFiles - to be converted.
      options - options to control processing (default: empty).
      Returns:
      returns an array of 0 positions if the rendered output is written to a file.
    • convertFiles

      public String[] convertFiles(Collection<File> files, OptionsBuilder options)
      Description copied from interface: Asciidoctor
      Convert all files from a collection.
      Specified by:
      convertFiles in interface Asciidoctor
      Parameters:
      files - to be converted.
      options - a Map of options to control processing (default: {}).
      Returns:
      returns an array of 0 positions if the rendered output is written to a file.
    • load

      public Document load(String content, Map<String,Object> options)
      Description copied from interface: Asciidoctor
      Loads AsciiDoc content and returns the Document object.
      Specified by:
      load in interface Asciidoctor
      Parameters:
      content - to be parsed.
      options - a Map of options to control processing (default: {}).
      Returns:
      Document of given content.
    • load

      public Document load(String content, Options options)
      Description copied from interface: Asciidoctor
      Loads AsciiDoc content and returns the Document object.
      Specified by:
      load in interface Asciidoctor
      Parameters:
      content - to be parsed.
      options - options to control processing (default: empty).
      Returns:
      Document of given content.
    • loadFile

      public Document loadFile(File file, Map<String,Object> options)
      Description copied from interface: Asciidoctor
      Loads AsciiDoc content from file and returns the Document object.
      Specified by:
      loadFile in interface Asciidoctor
      Parameters:
      file - to be parsed.
      options - a Map of options to control processing (default: {}).
      Returns:
      Document of given content.
    • loadFile

      public Document loadFile(File file, Options options)
      Description copied from interface: Asciidoctor
      Loads AsciiDoc content from file and returns the Document object.
      Specified by:
      loadFile in interface Asciidoctor
      Parameters:
      file - to be parsed.
      options - options to control processing (default: empty).
      Returns:
      Document of given content.
    • createGroup

      public ExtensionGroup createGroup()
      Description copied from interface: Asciidoctor
      Creates an ExtensionGroup that can be used to register and unregister multiples extensions all at once.
      Specified by:
      createGroup in interface Asciidoctor
      Returns:
      Extension Group instance.
    • createGroup

      public ExtensionGroup createGroup(String groupName)
      Description copied from interface: Asciidoctor
      Creates an ExtensionGroup that can be used to register and unregister multiples extensions all at once.
      Specified by:
      createGroup in interface Asciidoctor
      Parameters:
      groupName - to assign to the ExtensionGroup.
      Returns:
      Extension Group instance.
    • log

      public void log(LogRecord logRecord)
      Description copied from interface: LogHandler
      Process a log record. This method is called during conversion and will abort completely if an exception is thrown from within.
      Specified by:
      log in interface LogHandler