Class Processor

java.lang.Object
com.github.rjeschke.txtmark.Processor

public class Processor extends Object
Markdown processor class.

Example usage:

String result = Processor.process("This is ***TXTMARK***");

  • Field Details

    • reader

      private final Reader reader
      The reader.
    • emitter

      private final Emitter emitter
      The emitter.
    • config

      final Configuration config
      The Configuration.
    • useExtensions

      private boolean useExtensions
      Extension flag.
  • Constructor Details

    • Processor

      private Processor(Reader reader, Configuration config)
      Constructor.
      Parameters:
      reader - The input reader.
  • Method Details

    • process

      public static final String process(Reader reader, Configuration configuration) throws IOException
      Transforms an input stream into HTML using the given Configuration.
      Parameters:
      reader - The Reader to process.
      configuration - The Configuration.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      Since:
      0.7
      See Also:
    • process

      public static final String process(String input, Configuration configuration)
      Transforms an input String into HTML using the given Configuration.
      Parameters:
      input - The String to process.
      configuration - The Configuration.
      Returns:
      The processed String.
      Since:
      0.7
      See Also:
    • process

      public static final String process(File file, Configuration configuration) throws IOException
      Transforms an input file into HTML using the given Configuration.
      Parameters:
      file - The File to process.
      configuration - the Configuration
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      Since:
      0.7
      See Also:
    • process

      public static final String process(InputStream input, Configuration configuration) throws IOException
      Transforms an input stream into HTML using the given Configuration.
      Parameters:
      input - The InputStream to process.
      configuration - The Configuration.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      Since:
      0.7
      See Also:
    • process

      public static final String process(String input)
      Transforms an input String into HTML using the default Configuration.
      Parameters:
      input - The String to process.
      Returns:
      The processed String.
      See Also:
    • process

      public static final String process(String input, boolean safeMode)
      Transforms an input String into HTML.
      Parameters:
      input - The String to process.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      See Also:
    • process

      public static final String process(String input, Decorator decorator)
      Transforms an input String into HTML.
      Parameters:
      input - The String to process.
      decorator - The decorator to use.
      Returns:
      The processed String.
      See Also:
    • process

      public static final String process(String input, Decorator decorator, boolean safeMode)
      Transforms an input String into HTML.
      Parameters:
      input - The String to process.
      decorator - The decorator to use.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      See Also:
    • process

      public static final String process(File file) throws IOException
      Transforms an input file into HTML using the default Configuration.
      Parameters:
      file - The File to process.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(File file, boolean safeMode) throws IOException
      Transforms an input file into HTML.
      Parameters:
      file - The File to process.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(File file, Decorator decorator) throws IOException
      Transforms an input file into HTML.
      Parameters:
      file - The File to process.
      decorator - The decorator to use.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(File file, Decorator decorator, boolean safeMode) throws IOException
      Transforms an input file into HTML.
      Parameters:
      file - The File to process.
      decorator - The decorator to use.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(File file, String encoding) throws IOException
      Transforms an input file into HTML.
      Parameters:
      file - The File to process.
      encoding - The encoding to use.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(File file, String encoding, boolean safeMode) throws IOException
      Transforms an input file into HTML.
      Parameters:
      file - The File to process.
      encoding - The encoding to use.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(File file, String encoding, Decorator decorator) throws IOException
      Transforms an input file into HTML.
      Parameters:
      file - The File to process.
      encoding - The encoding to use.
      decorator - The decorator to use.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(File file, String encoding, Decorator decorator, boolean safeMode) throws IOException
      Transforms an input file into HTML.
      Parameters:
      file - The File to process.
      encoding - The encoding to use.
      decorator - The decorator to use.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(InputStream input) throws IOException
      Transforms an input stream into HTML.
      Parameters:
      input - The InputStream to process.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(InputStream input, boolean safeMode) throws IOException
      Transforms an input stream into HTML.
      Parameters:
      input - The InputStream to process.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(InputStream input, Decorator decorator) throws IOException
      Transforms an input stream into HTML.
      Parameters:
      input - The InputStream to process.
      decorator - The decorator to use.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(InputStream input, Decorator decorator, boolean safeMode) throws IOException
      Transforms an input stream into HTML.
      Parameters:
      input - The InputStream to process.
      decorator - The decorator to use.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(InputStream input, String encoding) throws IOException
      Transforms an input stream into HTML.
      Parameters:
      input - The InputStream to process.
      encoding - The encoding to use.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(InputStream input, String encoding, boolean safeMode) throws IOException
      Transforms an input stream into HTML.
      Parameters:
      input - The InputStream to process.
      encoding - The encoding to use.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(InputStream input, String encoding, Decorator decorator) throws IOException
      Transforms an input stream into HTML.
      Parameters:
      input - The InputStream to process.
      encoding - The encoding to use.
      decorator - The decorator to use.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(InputStream input, String encoding, Decorator decorator, boolean safeMode) throws IOException
      Transforms an input stream into HTML.
      Parameters:
      input - The InputStream to process.
      encoding - The encoding to use.
      decorator - The decorator to use.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(Reader reader) throws IOException
      Transforms an input stream into HTML using the default Configuration.
      Parameters:
      reader - The Reader to process.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(Reader reader, boolean safeMode) throws IOException
      Transforms an input stream into HTML.
      Parameters:
      reader - The Reader to process.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(Reader reader, Decorator decorator) throws IOException
      Transforms an input stream into HTML.
      Parameters:
      reader - The Reader to process.
      decorator - The decorator to use.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • process

      public static final String process(Reader reader, Decorator decorator, boolean safeMode) throws IOException
      Transforms an input stream into HTML.
      Parameters:
      reader - The Reader to process.
      decorator - The decorator to use.
      safeMode - Set to true to escape unsafe HTML tags.
      Returns:
      The processed String.
      Throws:
      IOException - if an IO error occurs
      See Also:
    • readLines

      private Block readLines() throws IOException
      Reads all lines from our reader.

      Takes care of markdown link references.

      Returns:
      A Block containing all lines.
      Throws:
      IOException - If an IO error occurred.
    • initListBlock

      private void initListBlock(Block root)
      Initializes a list block by separating it into list item blocks.
      Parameters:
      root - The Block to process.
    • recurse

      private void recurse(Block root, boolean listMode)
      Recursively process the given Block.
      Parameters:
      root - The Block to process.
      listMode - Flag indicating that we're in a list item block.
    • process

      private String process() throws IOException
      Does all the processing.
      Returns:
      The processed String.
      Throws:
      IOException - If an IO error occurred.