Encode non-alphanum chars like %, + in URLs in the docs

Use $itemSymOrIDEnc instead of $itemSymOrID in the id and href attr in
a tags.

Fixes https://github.com/nim-lang/Nim/issues/9097.

Thanks to @LemonBoy for helping with this commit.

---

Update the tests too -- "nim c -r nimdoc/tester" passes.
This commit is contained in:
Kaushal Modi 2018-09-28 12:37:10 -04:00
commit de8cb0a1cf
3 changed files with 19 additions and 12 deletions

View file

@ -38,7 +38,8 @@ doc.section.toc = """
# * $seeSrc: generated HTML from doc.item.seesrc (if some switches are used).
doc.item = """
<dt id="$itemSym"><a name="$itemSymOrID"></a><pre>$header</pre></dt>
<a id="$itemSymOrIdEnc"></a>
<dt><pre>$header</pre></dt>
<dd>
$desc
$seeSrc
@ -48,7 +49,7 @@ $seeSrc
# Chunk of HTML emitted for each entry in the HTML table of contents.
# See doc.item for available substitution variables.
doc.item.toc = """
<li><a class="reference" href="#$itemSymOrID"
<li><a class="reference" href="#$itemSymOrIDEnc"
title="$header_plain">$name<span class="attachedType" style="visibility:hidden">$attype</span></a></li>
"""