mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 18:32:11 +00:00
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:
@@ -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>
|
||||
"""
|
||||
|
||||
|
||||
@@ -1250,7 +1250,7 @@ function main() {
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#someType,"
|
||||
<li><a class="reference" href="#someType%2C"
|
||||
title="someType(): SomeType"><wbr />some<wbr />Type<span class="attachedType" style="visibility:hidden">SomeType</span></a></li>
|
||||
|
||||
</ul>
|
||||
@@ -1265,7 +1265,8 @@ function main() {
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<dt id="SomeType"><a name="SomeType"></a><pre><a href="utils.html#SomeType"><span class="Identifier">SomeType</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
|
||||
<a id="SomeType"></a>
|
||||
<dt><pre><a href="utils.html#SomeType"><span class="Identifier">SomeType</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
|
||||
<span class="Identifier">enumValueA</span><span class="Other">,</span> <span class="Identifier">enumValueB</span><span class="Other">,</span> <span class="Identifier">enumValueC</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
@@ -1276,7 +1277,8 @@ function main() {
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<dt id="someType"><a name="someType,"></a><pre><span class="Keyword">proc</span> <span class="Identifier">someType</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="utils.html#SomeType"><span class="Identifier">SomeType</span></a> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
|
||||
<a id="someType%2C"></a>
|
||||
<dt><pre><span class="Keyword">proc</span> <span class="Identifier">someType</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="utils.html#SomeType"><span class="Identifier">SomeType</span></a> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
|
||||
<dd>
|
||||
constructor.
|
||||
|
||||
|
||||
@@ -1255,7 +1255,7 @@ function main() {
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#bar,T,T"
|
||||
<li><a class="reference" href="#bar%2CT%2CT"
|
||||
title="bar[T](a, b: T): T"><wbr />bar<span class="attachedType" style="visibility:hidden"></span></a></li>
|
||||
|
||||
</ul>
|
||||
@@ -1263,7 +1263,7 @@ function main() {
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#17" id="67">Macros</a>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#bar.m,"
|
||||
<li><a class="reference" href="#bar.m%2C"
|
||||
title="bar(): untyped"><wbr />bar<span class="attachedType" style="visibility:hidden"></span></a></li>
|
||||
|
||||
</ul>
|
||||
@@ -1271,7 +1271,7 @@ function main() {
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#18" id="68">Templates</a>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#foo.t,SomeType,SomeType"
|
||||
<li><a class="reference" href="#foo.t%2CSomeType%2CSomeType"
|
||||
title="foo(a, b: SomeType)"><wbr />foo<span class="attachedType" style="visibility:hidden"></span></a></li>
|
||||
|
||||
</ul>
|
||||
@@ -1297,7 +1297,8 @@ function main() {
|
||||
<div class="section" id="8">
|
||||
<h1><a class="toc-backref" href="#8">Vars</a></h1>
|
||||
<dl class="item">
|
||||
<dt id="aVariable"><a name="aVariable"></a><pre><span class="Identifier">aVariable</span><span class="Other">:</span> <span class="Identifier">array</span><span class="Other">[</span><span class="DecNumber">1</span><span class="Other">,</span> <span class="Identifier">int</span><span class="Other">]</span></pre></dt>
|
||||
<a id="aVariable"></a>
|
||||
<dt><pre><span class="Identifier">aVariable</span><span class="Other">:</span> <span class="Identifier">array</span><span class="Other">[</span><span class="DecNumber">1</span><span class="Other">,</span> <span class="Identifier">int</span><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
@@ -1307,7 +1308,8 @@ function main() {
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<dt id="bar"><a name="bar,T,T"></a><pre><span class="Keyword">proc</span> <span class="Identifier">bar</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span></pre></dt>
|
||||
<a id="bar%2CT%2CT"></a>
|
||||
<dt><pre><span class="Keyword">proc</span> <span class="Identifier">bar</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
@@ -1317,7 +1319,8 @@ function main() {
|
||||
<div class="section" id="17">
|
||||
<h1><a class="toc-backref" href="#17">Macros</a></h1>
|
||||
<dl class="item">
|
||||
<dt id="bar"><a name="bar.m,"></a><pre><span class="Keyword">macro</span> <span class="Identifier">bar</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
|
||||
<a id="bar.m%2C"></a>
|
||||
<dt><pre><span class="Keyword">macro</span> <span class="Identifier">bar</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
@@ -1327,7 +1330,8 @@ function main() {
|
||||
<div class="section" id="18">
|
||||
<h1><a class="toc-backref" href="#18">Templates</a></h1>
|
||||
<dl class="item">
|
||||
<dt id="foo"><a name="foo.t,SomeType,SomeType"></a><pre><span class="Keyword">template</span> <span class="Identifier">foo</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="subdir/subdir_b/utils.html#SomeType"><span class="Identifier">SomeType</span></a><span class="Other">)</span></pre></dt>
|
||||
<a id="foo.t%2CSomeType%2CSomeType"></a>
|
||||
<dt><pre><span class="Keyword">template</span> <span class="Identifier">foo</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="subdir/subdir_b/utils.html#SomeType"><span class="Identifier">SomeType</span></a><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
This does nothing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user