Class MarkdownParser
- java.lang.Object
-
- net.sf.okapi.filters.markdown.parser.MarkdownParser
-
public class MarkdownParser extends Object
-
-
Constructor Summary
Constructors Constructor Description MarkdownParser(Parameters params)Create a newMarkdownParserthat uses the platform-specific newline.MarkdownParser(Parameters params, String newline)Create a newMarkdownParserthat uses the specified string as a newline.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringdumpTokens()Dumps all tokens.StringgetNewline()MarkdownTokengetNextToken()Returns the next available token.booleanhasNextToken()voidparse(String markdownContent)Parse the given Markdown content into tokens that can be then retrieved with calls togetNextToken().voidsetNewline(String newline)StringtoString()Returns a string representation the AST generated by the parser from the last call toparse(String).
-
-
-
Constructor Detail
-
MarkdownParser
public MarkdownParser(Parameters params)
Create a newMarkdownParserthat uses the platform-specific newline.
-
MarkdownParser
public MarkdownParser(Parameters params, String newline)
Create a newMarkdownParserthat uses the specified string as a newline.- Parameters:
newline- The newline type that this parser will use
-
-
Method Detail
-
parse
public void parse(String markdownContent)
Parse the given Markdown content into tokens that can be then retrieved with calls togetNextToken(). Any existing tokens from previous calls toparse(String)will be discarded.- Parameters:
markdownContent- The Markdown content to parse into tokens
-
hasNextToken
public boolean hasNextToken()
-
getNextToken
public MarkdownToken getNextToken()
Returns the next available token.- Returns:
- The next token
- Throws:
IllegalStateException- If no more tokens are remaining
-
getNewline
public String getNewline()
-
setNewline
public void setNewline(String newline)
-
dumpTokens
public String dumpTokens()
Dumps all tokens. This is for development.- Returns:
- String representation of all MarkdownTokens generated.
-
toString
public String toString()
Returns a string representation the AST generated by the parser from the last call toparse(String).
System.out.println(markdownParser.toString())
is a convenient way to dump the parsed node tree during the development.
-
-