diff options
author | Juan Carlos <juancarlospaco@gmail.com> | 2020-06-12 05:51:55 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-12 10:51:55 +0200 |
commit | 82e424189ee4bf0f05fcf5695fe1c3e2d2dfc51f (patch) | |
tree | 316ef982d821000d9cfe37abba27b3cf0e3dd3ca /lib | |
parent | 1168c75381446f8c81ce3f5f329ce2dab238415c (diff) | |
download | Nim-82e424189ee4bf0f05fcf5695fe1c3e2d2dfc51f.tar.gz |
Add rstgen.rstToLatex convenience proc for renderRstToOut and initRstGenerator with outLatex output, see https://github.com/nim-lang/fusion/pull/11#issuecomment-641804899 (#14629)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/packages/docutils/rstgen.nim | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim index 6a7b33cc0..2ec25cc6e 100644 --- a/lib/packages/docutils/rstgen.nim +++ b/lib/packages/docutils/rstgen.nim @@ -29,6 +29,7 @@ import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils, algorithm, parseutils import "$lib/../compiler/nimpaths" import "$lib/../compiler/pathutils" +import ../../std/private/since const HtmlExt = "html" @@ -1344,6 +1345,16 @@ proc rstToHtml*(s: string, options: RstParseOptions, renderRstToOut(d, rst, result) +proc rstToLatex*(rstSource: string; options: RstParseOptions): string {.inline, since: (1, 3).} = + ## Convenience proc for `renderRstToOut` and `initRstGenerator`. + runnableExamples: doAssert rstToLatex("*Hello* **world**", {}) == """\emph{Hello} \textbf{world}""" + if rstSource.len == 0: return + var option: bool + var rstGenera: RstGenerator + rstGenera.initRstGenerator(outLatex, defaultConfig(), "input", options) + rstGenera.renderRstToOut(rstParse(rstSource, "", 1, 1, option, options), result) + + when isMainModule: assert rstToHtml("*Hello* **world**!", {}, newStringTable(modeStyleInsensitive)) == |