This module implements a reStructuredText parser. A large subset is implemented. Some features of the markdown wiki syntax are also supported.
RstParseOption = enum
roSkipPounds, ## skip ``#`` at line beginning (documentation
## embedded in Nim comments)
roSupportSmilies, ## make the RST parser support smilies like ``:)``
roSupportRawDirective, ## support the ``raw`` directive (don't support
## it for sandboxing)
roSupportMarkdown ## support additional features of markdownRstParseOptions = set[RstParseOption]
MsgClass = enum mcHint = "Hint", mcWarning = "Warning", mcError = "Error"
MsgKind = enum meCannotOpenFile, meExpected, meGridTableNotImplemented, meNewSectionExpected, meGeneralParseError, meInvalidDirective, mwRedefinitionOfLabel, mwUnknownSubstitution, mwUnsupportedLanguage, mwUnsupportedField
MsgHandler = proc (filename: string; line, col: int; msgKind: MsgKind; arg: string) {...}{.
closure.}FindFileHandler = proc (filename: string): string {...}{.closure.}EParseError = object of ValueError
proc whichMsgClass(k: MsgKind): MsgClass {...}{.raises: [], tags: [].}proc defaultMsgHandler(filename: string; line, col: int; msgkind: MsgKind; arg: string) {...}{.
procvar, raises: [ValueError, EParseError, IOError], tags: [WriteIOEffect].}exceptn and sets its msg field to message. Returns the new exception object. proc defaultFindFile(filename: string): string {...}{.procvar, raises: [],
tags: [ReadDirEffect].}proc addNodes(n: PRstNode): string {...}{.raises: [], tags: [].}proc rstnodeToRefname(n: PRstNode): string {...}{.raises: [], tags: [].}proc getFieldValue(n: PRstNode): string {...}{.raises: [], tags: [].}Returns the value of a specific rnField node.
This proc will assert if the node is not of the expected type. The empty string will be returned as a minimum. Any value in the rst will be stripped form leading/trailing whitespace.
proc getFieldValue(n: PRstNode; fieldname: string): string {...}{.raises: [], tags: [].}not (x == y). proc getArgument(n: PRstNode): string {...}{.raises: [], tags: [].}proc rstParse(text, filename: string; line, column: int; hasToc: var bool;
options: RstParseOptions; findFile: FindFileHandler = nil;
msgHandler: MsgHandler = nil): PRstNode {...}{.raises: [Exception],
tags: [ReadEnvEffect, RootEffect].}
© 2006–2018 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/rst.html