diff options
author | Xabier Bello <xbello@users.noreply.github.com> | 2020-12-08 10:44:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-08 10:44:07 +0100 |
commit | 4c533b2d92162980dc8fac2332b0eb0739dbda25 (patch) | |
tree | 51d81b1fd9f6aa309eb151deaf819a4dd3499d6c /tests | |
parent | 2297b9623843bb4c1dbd201a8fb57f9ec334c164 (diff) | |
download | Nim-4c533b2d92162980dc8fac2332b0eb0739dbda25.tar.gz |
Added Python to highlite module. (#16286)
* Added Python to highlite module. * Added the keywords for Python * Refactored the 'pythonLikeNextToken' into 'nimNextToken': - `lang` property added to GeneralTokenizer object, is set in `getNextToken`. - `nimNextToken` accepts `keywords` parameter, used for languages different from Nim. - Multiline comment available only for `langNim`.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdlib/trstgen.nim | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/stdlib/trstgen.nim b/tests/stdlib/trstgen.nim index 1bf73e146..8b12a89c4 100644 --- a/tests/stdlib/trstgen.nim +++ b/tests/stdlib/trstgen.nim @@ -188,13 +188,13 @@ not in table""" let input1 = """ Test 2 column/4 rows table: ==== === -H0 H1 +H0 H1 ==== === -A0 A1 +A0 A1 ==== === -A2 A3 +A2 A3 ==== === -A4 A5 +A4 A5 ==== === """ let output1 = rstToLatex(input1, {}) assert "{|X|X|}" in output1 # 2 columns @@ -360,3 +360,19 @@ Test1 let output1l = rstToLatex(input1, {}) assert "line block\\\\" in output1l assert "other line\\\\" in output1l + +suite "RST/Code highlight": + test "Basic Python code highlight": + let pythonCode = """ + .. code-block:: python + + def f_name(arg=42): + print(f"{arg}") + + """ + + let expected = """<blockquote><p><span class="Keyword">def</span> f_name<span class="Punctuation">(</span><span class="Punctuation">arg</span><span class="Operator">=</span><span class="DecNumber">42</span><span class="Punctuation">)</span><span class="Punctuation">:</span> + print<span class="Punctuation">(</span><span class="RawData">f"{arg}"</span><span class="Punctuation">)</span></p></blockquote>""" + + check strip(rstToHtml(pythonCode, {}, newStringTable(modeCaseSensitive))) == + strip(expected) |