rst

This module implements a reStructuredText parser. A large subset is implemented. Some features of the markdown wiki syntax are also supported.

Note: Import packages/docutils/rst to use this module

Types

RstParseOption = enum
  roSkipPounds, roSupportSmilies, roSupportRawDirective, roSupportMarkdown
options for the RST parser   Source Edit
RstParseOptions = set[RstParseOption]
  Source Edit
MsgClass = enum
  mcHint = "Hint", mcWarning = "Warning", mcError = "Error"
  Source Edit
MsgKind = enum
  meCannotOpenFile, meExpected, meGridTableNotImplemented, meNewSectionExpected,
  meGeneralParseError, meInvalidDirective, mwRedefinitionOfLabel,
  mwUnknownSubstitution, mwUnsupportedLanguage, mwUnsupportedField
the possible messages   Source Edit
MsgHandler = proc (filename: string; line, col: int; msgKind: MsgKind;
                   arg: string) {...}{.closure, gcsafe.}
what to do in case of an error   Source Edit
FindFileHandler = proc (filename: string): string {...}{.closure, gcsafe.}
  Source Edit
EParseError = object of ValueError
  Source Edit

Procs

proc whichMsgClass(k: MsgKind): MsgClass {...}{.raises: [], tags: [].}
returns which message class k belongs to.   Source Edit
proc defaultMsgHandler(filename: string; line, col: int; msgkind: MsgKind;
                       arg: string) {...}{.raises: [ValueError, EParseError, IOError],
                                      tags: [WriteIOEffect].}
  Source Edit
proc defaultFindFile(filename: string): string {...}{.raises: [],
    tags: [ReadDirEffect].}
  Source Edit
proc addNodes(n: PRstNode): string {...}{.raises: [], tags: [].}
  Source Edit
proc rstnodeToRefname(n: PRstNode): string {...}{.raises: [], tags: [].}
  Source Edit
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.

  Source Edit
proc getFieldValue(n: PRstNode; fieldname: string): string {...}{.raises: [],
    tags: [].}
  Source Edit
proc getArgument(n: PRstNode): string {...}{.raises: [], tags: [].}
  Source Edit
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].}
  Source Edit