Markdown code blocks migration part 7 (#20547)
This commit is contained in:
parent
13b3ea71da
commit
19ff746916
17 changed files with 426 additions and 411 deletions
|
|
@ -13,7 +13,7 @@
|
|||
##
|
||||
## You can use this to build your own syntax highlighting, check this example:
|
||||
##
|
||||
## .. code:: Nim
|
||||
## ```Nim
|
||||
## let code = """for x in $int.high: echo x.ord mod 2 == 0"""
|
||||
## var toknizr: GeneralTokenizer
|
||||
## initGeneralTokenizer(toknizr, code)
|
||||
|
|
@ -31,19 +31,20 @@
|
|||
## else:
|
||||
## echo toknizr.kind # All the kinds of tokens can be processed here.
|
||||
## echo substr(code, toknizr.start, toknizr.length + toknizr.start - 1)
|
||||
## ```
|
||||
##
|
||||
## The proc `getSourceLanguage` can get the language `enum` from a string:
|
||||
##
|
||||
## .. code:: Nim
|
||||
## ```Nim
|
||||
## for l in ["C", "c++", "jAvA", "Nim", "c#"]: echo getSourceLanguage(l)
|
||||
## ```
|
||||
##
|
||||
## There is also a `Cmd` pseudo-language supported, which is a simple generic
|
||||
## shell/cmdline tokenizer (UNIX shell/Powershell/Windows Command):
|
||||
## no escaping, no programming language constructs besides variable definition
|
||||
## at the beginning of line. It supports these operators:
|
||||
##
|
||||
## .. code:: Cmd
|
||||
## & && | || ( ) '' "" ; # for comments
|
||||
## ```Cmd
|
||||
## & && | || ( ) '' "" ; # for comments
|
||||
## ```
|
||||
##
|
||||
## Instead of escaping always use quotes like here
|
||||
## `nimgrep --ext:'nim|nims' file.name`:cmd: shows how to input ``|``.
|
||||
|
|
|
|||
|
|
@ -153,12 +153,12 @@ proc initRstGenerator*(g: var RstGenerator, target: OutputTarget,
|
|||
##
|
||||
## Example:
|
||||
##
|
||||
## .. code-block:: nim
|
||||
##
|
||||
## ```nim
|
||||
## import packages/docutils/rstgen
|
||||
##
|
||||
## var gen: RstGenerator
|
||||
## gen.initRstGenerator(outHtml, defaultConfig(), "filename", {})
|
||||
## ```
|
||||
g.config = config
|
||||
g.target = target
|
||||
g.tocPart = @[]
|
||||
|
|
@ -289,13 +289,12 @@ proc renderRstToOut*(d: var RstGenerator, n: PRstNode, result: var string) {.gcs
|
|||
## Before using this proc you need to initialise a ``RstGenerator`` with
|
||||
## ``initRstGenerator`` and parse a rst file with ``rstParse`` from the
|
||||
## `packages/docutils/rst module <rst.html>`_. Example:
|
||||
##
|
||||
## .. code-block:: nim
|
||||
##
|
||||
## ```nim
|
||||
## # ...configure gen and rst vars...
|
||||
## var generatedHtml = ""
|
||||
## renderRstToOut(gen, rst, generatedHtml)
|
||||
## echo generatedHtml
|
||||
## ```
|
||||
|
||||
proc renderAux(d: PDoc, n: PRstNode, result: var string) =
|
||||
for i in countup(0, len(n)-1): renderRstToOut(d, n.sons[i], result)
|
||||
|
|
@ -1602,12 +1601,13 @@ proc rstToHtml*(s: string, options: RstParseOptions,
|
|||
## work. For an explanation of the ``config`` parameter see the
|
||||
## ``initRstGenerator`` proc. Example:
|
||||
##
|
||||
## .. code-block:: nim
|
||||
## ```nim
|
||||
## import packages/docutils/rstgen, strtabs
|
||||
##
|
||||
## echo rstToHtml("*Hello* **world**!", {},
|
||||
## newStringTable(modeStyleInsensitive))
|
||||
## # --> <em>Hello</em> <strong>world</strong>!
|
||||
## ```
|
||||
##
|
||||
## If you need to allow the rst ``include`` directive or tweak the generated
|
||||
## output you have to create your own ``RstGenerator`` with
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue