rst: minor fixes (#18960)
This commit is contained in:
parent
b2873f0f63
commit
f03872d99e
4 changed files with 5 additions and 4 deletions
|
|
@ -172,6 +172,7 @@
|
||||||
## ``header``, ``footer``, ``meta``, ``class``
|
## ``header``, ``footer``, ``meta``, ``class``
|
||||||
## - no ``role`` directives and no custom interpreted text roles
|
## - no ``role`` directives and no custom interpreted text roles
|
||||||
## - some standard roles are not supported (check `RST roles list`_)
|
## - some standard roles are not supported (check `RST roles list`_)
|
||||||
|
## - no generic admonition support
|
||||||
## * inline markup
|
## * inline markup
|
||||||
## - no simple-inline-markup
|
## - no simple-inline-markup
|
||||||
## - no embedded aliases
|
## - no embedded aliases
|
||||||
|
|
|
||||||
|
|
@ -381,7 +381,7 @@ proc renderRstToText*(node: PRstNode): string =
|
||||||
result.add renderRstToText(node.sons[i])
|
result.add renderRstToText(node.sons[i])
|
||||||
if node.kind in code: result.add "`"
|
if node.kind in code: result.add "`"
|
||||||
|
|
||||||
proc renderRstToStr*(node: PRstNode, indent=0): string =
|
proc treeRepr*(node: PRstNode, indent=0): string =
|
||||||
## Writes the parsed RST `node` into an AST tree with compact string
|
## Writes the parsed RST `node` into an AST tree with compact string
|
||||||
## representation in the format (one line per every sub-node):
|
## representation in the format (one line per every sub-node):
|
||||||
## ``indent - kind - [text|level|order|adType] - anchor (if non-zero)``
|
## ``indent - kind - [text|level|order|adType] - anchor (if non-zero)``
|
||||||
|
|
@ -411,4 +411,4 @@ proc renderRstToStr*(node: PRstNode, indent=0): string =
|
||||||
result.add (if node.anchor == "": "" else: " anchor='" & node.anchor & "'")
|
result.add (if node.anchor == "": "" else: " anchor='" & node.anchor & "'")
|
||||||
result.add "\n"
|
result.add "\n"
|
||||||
for son in node.sons:
|
for son in node.sons:
|
||||||
result.add renderRstToStr(son, indent=indent+2)
|
result.add treeRepr(son, indent=indent+2)
|
||||||
|
|
|
||||||
|
|
@ -1164,7 +1164,7 @@ proc renderAdmonition(d: PDoc, n: PRstNode, result: var string) =
|
||||||
case n.adType
|
case n.adType
|
||||||
of "hint", "note", "tip":
|
of "hint", "note", "tip":
|
||||||
htmlCls = "admonition-info"; texSz = "\\normalsize"; texColor = "green"
|
htmlCls = "admonition-info"; texSz = "\\normalsize"; texColor = "green"
|
||||||
of "attention", "admonition", "important", "warning":
|
of "attention", "admonition", "important", "warning", "caution":
|
||||||
htmlCls = "admonition-warning"; texSz = "\\large"; texColor = "orange"
|
htmlCls = "admonition-warning"; texSz = "\\large"; texColor = "orange"
|
||||||
of "danger", "error":
|
of "danger", "error":
|
||||||
htmlCls = "admonition-error"; texSz = "\\Large"; texColor = "red"
|
htmlCls = "admonition-error"; texSz = "\\Large"; texColor = "red"
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ proc toAst(input: string,
|
||||||
|
|
||||||
var (rst, _, _) = rstParse(input, filen, line=LineRstInit, column=ColRstInit,
|
var (rst, _, _) = rstParse(input, filen, line=LineRstInit, column=ColRstInit,
|
||||||
rstOptions, myFindFile, testMsgHandler)
|
rstOptions, myFindFile, testMsgHandler)
|
||||||
result = renderRstToStr(rst)
|
result = treeRepr(rst)
|
||||||
except EParseError as e:
|
except EParseError as e:
|
||||||
if e.msg != "":
|
if e.msg != "":
|
||||||
result = e.msg
|
result = e.msg
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue