Package com.github.rjeschke.txtmark
Class Processor
- java.lang.Object
-
- com.github.rjeschke.txtmark.Processor
-
public class Processor extends java.lang.ObjectMarkdown processor class.Example usage:
String result = Processor.process("This is ***TXTMARK***");
-
-
Field Summary
Fields Modifier and Type Field Description (package private) ConfigurationconfigThe Configuration.private EmitteremitterThe emitter.private java.io.ReaderreaderThe reader.private booleanuseExtensionsExtension flag.
-
Constructor Summary
Constructors Modifier Constructor Description privateProcessor(java.io.Reader reader, Configuration config)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidinitListBlock(Block root)Initializes a list block by separating it into list item blocks.private java.lang.Stringprocess()Does all the processing.static java.lang.Stringprocess(java.io.File file)Transforms an input file into HTML using the default Configuration.static java.lang.Stringprocess(java.io.File file, boolean safeMode)Transforms an input file into HTML.static java.lang.Stringprocess(java.io.File file, Configuration configuration)Transforms an input file into HTML using the given Configuration.static java.lang.Stringprocess(java.io.File file, Decorator decorator)Transforms an input file into HTML.static java.lang.Stringprocess(java.io.File file, Decorator decorator, boolean safeMode)Transforms an input file into HTML.static java.lang.Stringprocess(java.io.File file, java.lang.String encoding)Transforms an input file into HTML.static java.lang.Stringprocess(java.io.File file, java.lang.String encoding, boolean safeMode)Transforms an input file into HTML.static java.lang.Stringprocess(java.io.File file, java.lang.String encoding, Decorator decorator)Transforms an input file into HTML.static java.lang.Stringprocess(java.io.File file, java.lang.String encoding, Decorator decorator, boolean safeMode)Transforms an input file into HTML.static java.lang.Stringprocess(java.io.InputStream input)Transforms an input stream into HTML.static java.lang.Stringprocess(java.io.InputStream input, boolean safeMode)Transforms an input stream into HTML.static java.lang.Stringprocess(java.io.InputStream input, Configuration configuration)Transforms an input stream into HTML using the given Configuration.static java.lang.Stringprocess(java.io.InputStream input, Decorator decorator)Transforms an input stream into HTML.static java.lang.Stringprocess(java.io.InputStream input, Decorator decorator, boolean safeMode)Transforms an input stream into HTML.static java.lang.Stringprocess(java.io.InputStream input, java.lang.String encoding)Transforms an input stream into HTML.static java.lang.Stringprocess(java.io.InputStream input, java.lang.String encoding, boolean safeMode)Transforms an input stream into HTML.static java.lang.Stringprocess(java.io.InputStream input, java.lang.String encoding, Decorator decorator)Transforms an input stream into HTML.static java.lang.Stringprocess(java.io.InputStream input, java.lang.String encoding, Decorator decorator, boolean safeMode)Transforms an input stream into HTML.static java.lang.Stringprocess(java.io.Reader reader)Transforms an input stream into HTML using the default Configuration.static java.lang.Stringprocess(java.io.Reader reader, boolean safeMode)Transforms an input stream into HTML.static java.lang.Stringprocess(java.io.Reader reader, Configuration configuration)Transforms an input stream into HTML using the given Configuration.static java.lang.Stringprocess(java.io.Reader reader, Decorator decorator)Transforms an input stream into HTML.static java.lang.Stringprocess(java.io.Reader reader, Decorator decorator, boolean safeMode)Transforms an input stream into HTML.static java.lang.Stringprocess(java.lang.String input)Transforms an input String into HTML using the default Configuration.static java.lang.Stringprocess(java.lang.String input, boolean safeMode)Transforms an input String into HTML.static java.lang.Stringprocess(java.lang.String input, Configuration configuration)Transforms an input String into HTML using the given Configuration.static java.lang.Stringprocess(java.lang.String input, Decorator decorator)Transforms an input String into HTML.static java.lang.Stringprocess(java.lang.String input, Decorator decorator, boolean safeMode)Transforms an input String into HTML.private BlockreadLines()Reads all lines from our reader.private voidrecurse(Block root, boolean listMode)Recursively process the given Block.
-
-
-
Field Detail
-
reader
private final java.io.Reader reader
The reader.
-
emitter
private final Emitter emitter
The emitter.
-
config
final Configuration config
The Configuration.
-
useExtensions
private boolean useExtensions
Extension flag.
-
-
Constructor Detail
-
Processor
private Processor(java.io.Reader reader, Configuration config)Constructor.- Parameters:
reader- The input reader.
-
-
Method Detail
-
process
public static final java.lang.String process(java.io.Reader reader, Configuration configuration) throws java.io.IOExceptionTransforms an input stream into HTML using the given Configuration.- Parameters:
reader- The Reader to process.configuration- The Configuration.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- Since:
- 0.7
- See Also:
Configuration
-
process
public static final java.lang.String process(java.lang.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:
Configuration
-
process
public static final java.lang.String process(java.io.File file, Configuration configuration) throws java.io.IOExceptionTransforms an input file into HTML using the given Configuration.- Parameters:
file- The File to process.configuration- the Configuration- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- Since:
- 0.7
- See Also:
Configuration
-
process
public static final java.lang.String process(java.io.InputStream input, Configuration configuration) throws java.io.IOExceptionTransforms an input stream into HTML using the given Configuration.- Parameters:
input- The InputStream to process.configuration- The Configuration.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- Since:
- 0.7
- See Also:
Configuration
-
process
public static final java.lang.String process(java.lang.String input)
Transforms an input String into HTML using the default Configuration.- Parameters:
input- The String to process.- Returns:
- The processed String.
- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.lang.String input, boolean safeMode)Transforms an input String into HTML.- Parameters:
input- The String to process.safeMode- Set totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.lang.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:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.lang.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 totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.File file) throws java.io.IOExceptionTransforms an input file into HTML using the default Configuration.- Parameters:
file- The File to process.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.File file, boolean safeMode) throws java.io.IOExceptionTransforms an input file into HTML.- Parameters:
file- The File to process.safeMode- Set totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.File file, Decorator decorator) throws java.io.IOExceptionTransforms an input file into HTML.- Parameters:
file- The File to process.decorator- The decorator to use.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.File file, Decorator decorator, boolean safeMode) throws java.io.IOExceptionTransforms an input file into HTML.- Parameters:
file- The File to process.decorator- The decorator to use.safeMode- Set totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.File file, java.lang.String encoding) throws java.io.IOExceptionTransforms an input file into HTML.- Parameters:
file- The File to process.encoding- The encoding to use.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.File file, java.lang.String encoding, boolean safeMode) throws java.io.IOExceptionTransforms an input file into HTML.- Parameters:
file- The File to process.encoding- The encoding to use.safeMode- Set totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.File file, java.lang.String encoding, Decorator decorator) throws java.io.IOExceptionTransforms 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:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.File file, java.lang.String encoding, Decorator decorator, boolean safeMode) throws java.io.IOExceptionTransforms an input file into HTML.- Parameters:
file- The File to process.encoding- The encoding to use.decorator- The decorator to use.safeMode- Set totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.InputStream input) throws java.io.IOExceptionTransforms an input stream into HTML.- Parameters:
input- The InputStream to process.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.InputStream input, boolean safeMode) throws java.io.IOExceptionTransforms an input stream into HTML.- Parameters:
input- The InputStream to process.safeMode- Set totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.InputStream input, Decorator decorator) throws java.io.IOExceptionTransforms an input stream into HTML.- Parameters:
input- The InputStream to process.decorator- The decorator to use.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.InputStream input, Decorator decorator, boolean safeMode) throws java.io.IOExceptionTransforms an input stream into HTML.- Parameters:
input- The InputStream to process.decorator- The decorator to use.safeMode- Set totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.InputStream input, java.lang.String encoding) throws java.io.IOExceptionTransforms an input stream into HTML.- Parameters:
input- The InputStream to process.encoding- The encoding to use.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.InputStream input, java.lang.String encoding, boolean safeMode) throws java.io.IOExceptionTransforms an input stream into HTML.- Parameters:
input- The InputStream to process.encoding- The encoding to use.safeMode- Set totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.InputStream input, java.lang.String encoding, Decorator decorator) throws java.io.IOExceptionTransforms 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:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.InputStream input, java.lang.String encoding, Decorator decorator, boolean safeMode) throws java.io.IOExceptionTransforms an input stream into HTML.- Parameters:
input- The InputStream to process.encoding- The encoding to use.decorator- The decorator to use.safeMode- Set totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.Reader reader) throws java.io.IOExceptionTransforms an input stream into HTML using the default Configuration.- Parameters:
reader- The Reader to process.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.Reader reader, boolean safeMode) throws java.io.IOExceptionTransforms an input stream into HTML.- Parameters:
reader- The Reader to process.safeMode- Set totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.Reader reader, Decorator decorator) throws java.io.IOExceptionTransforms an input stream into HTML.- Parameters:
reader- The Reader to process.decorator- The decorator to use.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
process
public static final java.lang.String process(java.io.Reader reader, Decorator decorator, boolean safeMode) throws java.io.IOExceptionTransforms an input stream into HTML.- Parameters:
reader- The Reader to process.decorator- The decorator to use.safeMode- Set totrueto escape unsafe HTML tags.- Returns:
- The processed String.
- Throws:
java.io.IOException- if an IO error occurs- See Also:
Configuration.DEFAULT
-
readLines
private Block readLines() throws java.io.IOException
Reads all lines from our reader.Takes care of markdown link references.
- Returns:
- A Block containing all lines.
- Throws:
java.io.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 java.lang.String process() throws java.io.IOExceptionDoes all the processing.- Returns:
- The processed String.
- Throws:
java.io.IOException- If an IO error occurred.
-
-