Class MarkdownWriter
java.lang.Object
java.io.Writer
org.apache.juneau.marshall.serializer.SerializerWriter<MarkdownWriter>
org.apache.juneau.marshall.markdown.MarkdownWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
Low-level Markdown writer providing helper methods for producing Markdown output.
Extends SerializerWriter to provide Markdown-specific output helpers for headings,
tables, lists, and inline formatting.
Notes:
- This class is not thread safe and is typically discarded after one use.
-
Field Summary
Fields inherited from class org.apache.juneau.marshall.serializer.SerializerWriter
maxIndent, out, quoteChar, trimStrings, uriResolver, useWhitespace -
Constructor Summary
ConstructorsConstructorDescriptionMarkdownWriter(Writer out, boolean useWhitespace, int maxIndent, boolean trimStrings, UriResolver uriResolver) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionWrites a blank line.Writes bold text.bulletItem(int depth, String text) Writes a Markdown bulleted list item.Writes text wrapped in backticks (inline code).static StringescapeCell(String text) Escapes a string for use inside a Markdown table cell.static StringescapeText(String text) Escapes a string for use in general Markdown text.Writes a Markdown heading at the specified level.Writes a Markdown horizontal rule.Writes italic text.tableHeader(String... columns) Writes a Markdown table header row.Writes a Markdown table data row.tableSeparator(int numColumns) Writes a Markdown table separator row.Writes plain text with Markdown escaping.
-
Constructor Details
-
MarkdownWriter
public MarkdownWriter(Writer out, boolean useWhitespace, int maxIndent, boolean trimStrings, UriResolver uriResolver) Constructor.- Parameters:
out- The underlying writer.useWhitespace- Whether to use whitespace formatting.maxIndent- The maximum indentation level.trimStrings- Whether to trim strings.uriResolver- The URI resolver for resolving relative URIs.
-
-
Method Details
-
heading
Writes a Markdown heading at the specified level.- Parameters:
level- The heading level (1-6).text- The heading text.
Can benull (written as an empty string).- Returns:
- This object.
- Throws:
IOException- Thrown by underlying stream.
-
tableHeader
Writes a Markdown table header row.- Parameters:
columns- The column names.
Individual column names can benull (written as an empty cell).- Returns:
- This object.
- Throws:
IOException- Thrown by underlying stream.
-
tableSeparator
Writes a Markdown table separator row.- Parameters:
numColumns- The number of columns.- Returns:
- This object.
- Throws:
IOException- Thrown by underlying stream.
-
tableRow
Writes a Markdown table data row.- Parameters:
values- The cell values.
Individual values can benull (written as an empty cell).- Returns:
- This object.
- Throws:
IOException- Thrown by underlying stream.
-
bulletItem
Writes a Markdown bulleted list item.- Parameters:
depth- The indentation depth (0 = no indent).text- The item text.
Can benull (written as an empty string).- Returns:
- This object.
- Throws:
IOException- Thrown by underlying stream.
-
horizontalRule
Writes a Markdown horizontal rule.- Returns:
- This object.
- Throws:
IOException- Thrown by underlying stream.
-
blankLine
Writes a blank line.- Returns:
- This object.
- Throws:
IOException- Thrown by underlying stream.
-
text
Writes plain text with Markdown escaping.- Parameters:
text- The text to write.
Can benull (written as an empty string).- Returns:
- This object.
- Throws:
IOException- Thrown by underlying stream.
-
code
Writes text wrapped in backticks (inline code).- Parameters:
text- The text to render as code.
Can benull (written as an empty string).- Returns:
- This object.
- Throws:
IOException- Thrown by underlying stream.
-
bold
Writes bold text.- Parameters:
text- The text to render bold.
Can benull (written as an empty string).- Returns:
- This object.
- Throws:
IOException- Thrown by underlying stream.
-
italic
Writes italic text.- Parameters:
text- The text to render italic.
Can benull (written as an empty string).- Returns:
- This object.
- Throws:
IOException- Thrown by underlying stream.
-
escapeCell
Escapes a string for use inside a Markdown table cell.Escapes pipe characters and backslashes. Replaces newlines with
<br>.- Parameters:
text- The raw text.
Can benull (returns an empty string).- Returns:
- The escaped text suitable for a table cell. Never
null .
-
escapeText
Escapes a string for use in general Markdown text.Escapes backslashes and leading Markdown special characters.
- Parameters:
text- The raw text.
Can benull (returns an empty string).- Returns:
- The escaped text. Never
null .
-