Utils for markdown AST.
Code Map
//! Utils for markdown AST.
module watt.markdown.util;
enum CODE_INDENT;
//! State for email validator.
enum EmailState
{
BeforeAt,
DomainStart,
DomainBody,
}
//! Create a Document node and return it.
fn buildDocument() Document { }
//! Create a BlockQuote node, add it to children and return it.
fn addBlockQuote(children: Node[]) BlockQuote { }
//! Create a List node, add it to children and return it.
fn addList(children: Node[]) List { }
//! Create a Item node, add it to children and return it.
fn addItem(children: Node[]) Item { }
//! Create a CodeBlock node, add it to children and return it.
fn addCodeBlock(children: Node[], str: string, info: string) CodeBlock { }
//! Create a HtmlBlock node, add it to children and return it.
fn addHtmlBlock(children: Node[], str: string) HtmlBlock { }
//! Create an HtmlBlock node.
fn buildHtmlBlock() HtmlBlock { }
//! Create a Paragraph node, add it to children and return it.
fn addParagraph(children: Node[]) Paragraph { }
//! Create a Paragraph node, don't add it anywhere.
fn buildParagraph() Paragraph { }
//! Create a Heading node, add it to children and return it.
fn addHeading(children: Node[], level: u32) Heading { }
//! Create a Heading node, don't add it anywhere.
fn buildHeading(level: u32) Heading { }
//! Create a ThematicBreak node, add it to children and return it.
fn addThematicBreak(children: Node[]) ThematicBreak { }
//! Create a Text node, add it to children and return it.
fn addText(children: Node[], str: string) Text { }
//! Create a Text node, don't add it anywhere.
fn buildText(str: string) Text { }
//! Create a Softbreak node, add it to children and return it.
fn addSoftbreak(children: Node[]) Softbreak { }
//! Create a Linebreak node, add it to children and return it.
fn addLinebreak(children: Node[]) Linebreak { }
//! Create a Code node, add it to children and return it.
fn addCode(children: Node[], str: string) Code { }
//! Create a Code node.
fn buildCode(str: string) Code { }
//! Create an HtmlInline node, add it to children and return it.
fn addHtmlInline(children: Node[], str: string) HtmlInline { }
//! Build an HtmlInline node.
fn buildHtmlInline(str: string) HtmlInline { }
//! Create a Emph node, add it to children and return it.
fn addEmph(children: Node[]) Emph { }
//! Create a Emph node, don't add it anywhere.
fn buildEmph() Emph { }
//! Create a Strong node, don't add it anywhere.
fn buildStrong() Strong { }
//! Create a Strong node, add it to children and return it.
fn addStrong(children: Node[]) Strong { }
//! Create a Link node, add it to children and return it.
fn addLink(children: Node[], url: string, title: string) Link { }
//! Create a Link node.
fn buildLink() Link { }
//! Create a Link node.
fn buildLink(url: string, title: string) Link { }
//! Create a Image node, add it to children and return it.
fn addImage(children: Node[], url: string, title: string) Image { }
//! Build an Image node.
fn buildImage(url: string, alt: string, title: string) Image { }
//! Consume characters until a character is found.
fn consumeUntilChar(str: string, outStr: string, c: char) bool { }
//! Consume a link tag.
fn consumeTag(str: string, tag: string) bool { }
//! Consume one character.
fn consumeChar(str: string, c: char) bool { }
//! Consume whitespace.
fn consumeWhitespace(str: string) { }
//! Consume a URL.
fn consumeUrl(str: string, url: string) bool { }
//! Count the whitespace at the beginning of a string.
fn countLeadingWhitespace(str: string) size_t { }
//! Starting from i, count how much whitespace until the first
//! nonwhitespace character. If as much or more whitespace than maxLength
//! is counted, return immediately. Tabs count as 4.
fn countContiguousWhitespace(str: string, maxLength: size_t, i: size_t) size_t { }
//! Remove a delimiter length worth of characters from the front of str.
//! Taking into account tabs etc.
fn removeDelimiter(str: string, delimiter: size_t, forceFourTab: bool) string { }
//! Create a string filled with spaces len characters long.
fn emptyString(len: size_t) string { }
//! Create a string len characters long, filled with c characters.
fn uniformString(len: size_t, c: char) string { }
//! Get the string representation of a paragraph.
fn paragraphToString(p: Paragraph) string { }
fn markdownPunctuation(c: dchar) bool { }
//! Turn consecutive whitespace into a single whitespace.
fn collapseWhitespace(str: string) string { }
//! Escape a string using markdown escape rules.
fn markdownEscape(str: string) string { }
//! Build an AutoLink node.
fn makeAutoLink(url: string) Node { }
//! Build an EmailLink node.
fn makeEmailLink(url: string) Node { }
//! Build an AutoLinkNode.
fn makeStandaloneAutoLink(url: string) Node { }
fn isAbsoluteURI(str: string) bool { }
//! Percent encode a given url string. This isn't quite 'standard' in a few
//! ways:
fn urlEscape(str: string) string { }
//! Escape HTML entities.
fn htmlEntityEscape(str: string) string { }
fn isEmailAddress(str: string) bool { }
//! Is the string valid to be an HTML block?
fn validBlockHtml(str: string) bool { }
fn validInlineHtml(str: string) bool { }
//! Strip characters from a string hat are not allowed in image link
//! titles.
fn altStringPresentation(str: string) string { }
//! Replace an HTML entity with the correct unicode character.
fn replaceEntity(str: string) string { }
Create a Document node and return it.
Create a BlockQuote node, add it to children
and return it.
Create a List node, add it to children
and return it.
Create a Item node, add it to children
and return it.
Create a CodeBlock node, add it to children
and return it.
Create a HtmlBlock node, add it to children
and return it.
Create an HtmlBlock node.
Create a Paragraph node, add it to children
and return it.
Create a Paragraph node, don't add it anywhere.
Create a Heading node, add it to children
and return it.
Create a Heading node, don't add it anywhere.
Create a ThematicBreak node, add it to children
and return it.
Create a Text node, add it to children
and return it.
Create a Text node, don't add it anywhere.
Create a Softbreak node, add it to children
and return it.
Create a Linebreak node, add it to children
and return it.
Create a Code node, add it to children
and return it.
Create a Code node.
Create an HtmlInline node, add it to children
and return it.
Build an HtmlInline node.
Create a Emph node, add it to children
and return it.
Create a Emph node, don't add it anywhere.
Create a Strong node, don't add it anywhere.
Create a Strong node, add it to children
and return it.
Create a Link node, add it to children
and return it.
Create a Link node.
Create a Image node, add it to children
and return it.
Build an Image node.
Consume characters until a character is found.
Consume a link tag.
Consume one character.
Consume whitespace.
Consume a URL.
Count the whitespace at the beginning of a string.
Starting from i
, count how much whitespace until the first nonwhitespace character.
If as much or more whitespace than maxLength
is counted, return immediately.
Tabs count as 4.
Remove a delimiter length worth of characters from the front of str
.
Taking into account tabs etc.
Create a string filled with spaces len
characters long.
Create a string len
characters long, filled with c
characters.
Get the string representation of a paragraph.
Return
true if c
is markdown punctuation.
Turn consecutive whitespace into a single whitespace.
Escape a string using markdown escape rules.
Build an AutoLink node.
Build an EmailLink node.
Build an AutoLinkNode.
Return
true
if str
is an absolute URI, according to markdown rules.
Percent encode a given url string. This isn't quite 'standard' in a few ways:
- % is never encoded. The test suite has a nasty habit of passing a half encoded URL, saying 'the spec doesn't actually care', but expecting it one way, so we don't encode it as %25.
- [] are encoded. The RFC for this stuff states that the brackets are permissible, and do not need to be encoded, but CommonMark expects them to be.
Escape HTML entities.
State for email validator.
Return
true
if str
could be an email address.
Is the string valid to be an HTML block?
This is all a bit hacky, but a full HTML parser seems out of scope. Basically these characters could be in a string or something, but if there's not been whitespace, there's no way they could be valid.
Return
true
if str
is valid inline HTML.
Strip characters from a string hat are not allowed in image link titles.
Replace an HTML entity with the correct unicode character.