type

MarkdownWriter

src @Js
class MarkdownWriter : Obj

Writer for Markdown (CommonMark) text.

constructors

fields

atLineStart

Wheter we're at the line start (not counting any prefixes), i.e.

lastChar

The last character that was written

methods

block

Enqueue a block separator to be written before the next text is written.

line

Write a newline (line terminator).

popPrefix

Remove the last prefix from the top of the stack

popRawEscape

Remove the last raw escape from the top of the stack

popTight

Remove the last "tight" setting from the top of the stack

pushPrefix

Push a prefix onto the top of the stack.

pushRawEscape

Escape the characters matching the supplied matcher, in all text (text and raw).

pushTight

Change whether blocks are tight or loose.

raw

Write the supplied string or character (raw/unescaped except if pushRawEscape was used).

text

Write the supplied string with escaping

writePrefix

Write a prefix

Slot Details

atLineStart

src Bool atLineStart := true { private set }

Wheter we're at the line start (not counting any prefixes), i.e. after a line or block.

block

src Void block()

Enqueue a block separator to be written before the next text is written. Block separators are not written straight away because if there are no more blocks to write, we don't want a separator (at the end of the document)

lastChar

src Int lastChar := 0 { private set }

The last character that was written

line

src Void line()

Write a newline (line terminator).

make

src new make(OutStream out)

popPrefix

src Void popPrefix()

Remove the last prefix from the top of the stack

popRawEscape

src Void popRawEscape()

Remove the last raw escape from the top of the stack

popTight

src Void popTight()

Remove the last "tight" setting from the top of the stack

pushPrefix

src Void pushPrefix(Str prefix)

Push a prefix onto the top of the stack. All prefixes are written at the beginning of each line, until the prefix is popped again.

pushRawEscape

src Void pushRawEscape(|Int->Bool| rawEscape)

Escape the characters matching the supplied matcher, in all text (text and raw). This might be usefult to extensions that add another layer of syntax, e.g. the tables extension that uses | to separate cells and needs all | characters to be escaped (even in code spans)

pushTight

src Void pushTight(Bool tight)

Change whether blocks are tight or loose. Loose is the default where blocks are separated by a blank line. Tight is where blocks are not separated by a blank line. Tight blocks are used in lists, if there are no blank lines within the list.

Note that changing this does not affect block separators that have already been enqueued with block, only future ones.

raw

src Void raw(Obj obj)

Write the supplied string or character (raw/unescaped except if pushRawEscape was used).

text

src Void text(Str s, |Int->Bool|? escape := null)

Write the supplied string with escaping

writePrefix

src Void writePrefix(Str prefix)

Write a prefix