Class MarkdownHelper
A convinent wrapper around a StringBuilder that allows you to build a
markdown file. Call the various addHeading, addText methods,
then at the end call writeToFile
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHeading(String text) Adds a markdown styled headingvoidaddHeading(String text, int level) Adds a markdown styled headingvoidaddLine()Adds two newlines.voidAdds the given String to the buffer, ensuring this ends with two newline characters.voidaddNestedContent(String content) Add content that may itself be markdown formatted with headings.voidaddRstClass(String className) Adds an rst-class directive.voidaddTable(nz.org.riskscape.engine.cli.Table table) voidvoidDirectly adds the given String to the bufferbuild()Returns the markdown as a StringwriteToFile(Path path, String filename) Writes the stored content to the given path.
-
Constructor Details
-
MarkdownHelper
public MarkdownHelper()
-
-
Method Details
-
build
Returns the markdown as a String
-
addHeading
Adds a markdown styled heading
-
addHeading
Adds a markdown styled heading
- Parameters:
level- The size of the heading (1 is biggest, higher numbers create subheadings.)
-
addLine
public void addLine()Adds two newlines. Equivalent to
addLine("") -
addLine
Adds the given String to the buffer, ensuring this ends with two newline characters. (This corresponds to one newline once the markdown is parsed)
-
addNestedContent
Add content that may itself be markdown formatted with headings.
Content is split on double line feeds so it can be added line by line. Should any line be a heading it will be prefixed with current heading prefix to effectively alter the heading level to suit the document the new content is being inserted into.
- Parameters:
content- markdown content to add
-
addRstClass
Adds an rst-class directive. The element that follows this will be given this class
-
addText
Directly adds the given String to the buffer
-
addTable
public void addTable(nz.org.riskscape.engine.cli.Table table) -
addTable
-
writeToFile
Writes the stored content to the given path.
- Returns:
- The path that was written to
- Throws:
IOException
-