This module implements an AST for the reStructuredText parser.
Types
RstNode {.acyclic, final.} = object anchor*: string ## anchor, internal link target ## (aka HTML id tag, aka Latex label/hypertarget) sons*: RstNodeSeq ## the node's sons
- AST node (result of RST parsing) Source Edit
RstNodeKind = enum rnInner, rnHeadline, rnOverline, rnMarkdownHeadline, rnTransition, rnParagraph, rnBulletList, rnBulletItem, rnEnumList, rnEnumItem, rnDefList, rnMdDefList, rnDefItem, rnDefName, rnDefBody, rnFieldList, rnField, rnFieldName, rnFieldBody, rnOptionList, rnOptionListItem, rnOptionGroup, rnOption, rnOptionString, rnOptionArgument, rnDescription, rnLiteralBlock, rnMarkdownBlockQuote, rnMarkdownBlockQuoteItem, rnLineBlock, rnLineBlockItem, rnBlockQuote, rnTable, rnGridTable, rnMarkdownTable, rnTableRow, rnTableHeaderCell, rnTableDataCell, rnFootnote, rnCitation, rnFootnoteGroup, rnStandaloneHyperlink, rnHyperlink, rnRstRef, rnPandocRef, rnInternalRef, rnFootnoteRef, rnNimdocRef, rnDirective, rnDirArg, rnRaw, rnTitle, rnContents, rnImage, rnFigure, rnCodeBlock, rnAdmonition, rnRawHtml, rnRawLatex, rnContainer, rnIndex, rnSubstitutionDef, rnInlineCode, rnCodeFragment, rnUnknownRole, rnSub, rnSup, rnIdx, rnEmphasis, rnStrongEmphasis, rnTripleEmphasis, rnInterpretedText, rnInlineLiteral, rnInlineTarget, rnSubstitutionReferences, rnSmiley, rnDefaultRole, rnLeaf
- the possible node kinds of an PRstNode Source Edit
Procs
proc addIfNotNil(father, son: PRstNode) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc newRstLeaf(s: string): PRstNode {....raises: [], tags: [], forbids: [].}
- Source Edit
proc newRstNode(kind: RstNodeKind; info: TLineInfo; sons: seq[PRstNode] = @[]): PRstNode {. ...raises: [], tags: [], forbids: [].}
- Source Edit
proc newRstNode(kind: RstNodeKind; s: string): PRstNode {....deprecated, raises: [], tags: [], forbids: [].}
- Source Edit
proc newRstNode(kind: RstNodeKind; sons: seq[PRstNode] = @[]; anchor = ""): PRstNode {. ...raises: [], tags: [], forbids: [].}
- Source Edit
proc renderRstToJson(node: PRstNode): string {....raises: [], tags: [], forbids: [].}
-
Writes the given RST node as JSON that is in the form
{ "kind":string node.kind, "text":optional string node.text, "level":optional int node.level, "sons":optional node array }Source Edit proc renderRstToRst(n: PRstNode; result: var string) {....raises: [Exception], tags: [RootEffect], forbids: [].}
- renders n into its string representation and appends to result. Source Edit
proc renderRstToText(node: PRstNode): string {....raises: [], tags: [], forbids: [].}
- minimal text representation of markup node Source Edit
proc treeRepr(node: PRstNode; indent = 0): string {....raises: [], tags: [], forbids: [].}
- Writes the parsed RST node into an AST tree with compact string representation in the format (one line per every sub-node): indent - kind - [text|level|order|adType] - anchor (if non-zero) (suitable for debugging of RST parsing). Source Edit