diff options
author | Andrey Makarov <ph.makarov@gmail.com> | 2021-05-06 11:58:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-06 10:58:01 +0200 |
commit | 436af88d8c436265c751bbbc0d76ef42aab0cdf0 (patch) | |
tree | 608eedcc3573b342ecd0eed2a16e9a129924660f /lib/packages/docutils/rst.nim | |
parent | 706562f661e49d06f63a1283525275fb70bb7073 (diff) | |
download | Nim-436af88d8c436265c751bbbc0d76ef42aab0cdf0.tar.gz |
follow-up #17837: add `Console` for interactive sessions (#17930)
* follow-up #17837: add `Console` for interactive sessions * fix Latex
Diffstat (limited to 'lib/packages/docutils/rst.nim')
-rw-r--r-- | lib/packages/docutils/rst.nim | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index 249c310b9..ea0d62e04 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -89,6 +89,8 @@ ## ## - generic command line highlighting roles: ## - ``:cmd:`` for commands and common shells syntax +## - ``:console:`` the same for interactive sessions +## (commands should be prepended by ``$``) ## - ``:program:`` for executable names [cmp:Sphinx]_ ## (one can just use ``:cmd:`` on single word) ## - ``:option:`` for command line options [cmp:Sphinx]_ @@ -168,6 +170,7 @@ import os, strutils, rstast, std/enumutils, algorithm, lists, sequtils, std/private/miscdollars +from highlite import SourceLanguage, getSourceLanguage type RstParseOption* = enum ## options for the RST parser @@ -549,10 +552,6 @@ proc defaultFindFile*(filename: string): string = proc defaultRole(options: RstParseOptions): string = if roNimFile in options: "nim" else: "literal" -# mirror highlite.nim sourceLanguageToStr with substitutions c++ cpp, c# csharp -const supportedLanguages = ["nim", "yaml", "python", "java", "c", - "cpp", "csharp", "cmd"] - proc whichRoleAux(sym: string): RstNodeKind = let r = sym.toLowerAscii case r @@ -566,7 +565,7 @@ proc whichRoleAux(sym: string): RstNodeKind = of "code": result = rnInlineLiteral of "program", "option", "tok": result = rnCodeFragment # c++ currently can be spelled only as cpp, c# only as csharp - elif r in supportedLanguages: + elif getSourceLanguage(r) != langNone: result = rnInlineCode else: # unknown role result = rnUnknownRole @@ -2614,7 +2613,7 @@ proc dirRole(p: var RstParser): PRstNode = result = parseDirective(p, rnDirective, {hasArg, hasOptions}, nil) # just check that language is supported, TODO: real role association let lang = getFieldValue(result, "language").strip - if lang != "" and lang notin supportedLanguages: + if lang != "" and getSourceLanguage(lang) == langNone: rstMessage(p, mwUnsupportedLanguage, lang) proc dirRawAux(p: var RstParser, result: var PRstNode, kind: RstNodeKind, |