Skip to content

Commit

Permalink
fix #14485 (#14487)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour authored May 29, 2020
1 parent e013ebc commit 579456d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
5 changes: 2 additions & 3 deletions compiler/renderverbatim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ proc renderNimCode*(result: var string, code: string, isLatex = false) =
buf.addEscaped(val)
let class = tokenClassToStr[kind]
if isLatex:
result.addf "\\span$1{$2}" % [class, buf]
result.addf "\\span$1{$2}", [class, buf]
else:
result.addf "<span class=\"$1\">$2</span>" % [class, buf]

result.addf "<span class=\"$1\">$2</span>", [class, buf]
while true:
getNextToken(toknizr, langNim)
case toknizr.kind
Expand Down
21 changes: 21 additions & 0 deletions nimdoc/testproject/expected/testproject.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ <h1 class="title">testproject</h1>
title="z17()"><wbr />z17<span class="attachedType"></span></a></li>
<li><a class="reference" href="#p1"
title="p1()"><wbr />p1<span class="attachedType"></span></a></li>
<li><a class="reference" href="#addfBug14485"
title="addfBug14485()"><wbr />addf<wbr />Bug14485<span class="attachedType"></span></a></li>

</ul>
</li>
Expand Down Expand Up @@ -525,6 +527,25 @@ <h1><a class="toc-backref" href="#12">Procs</a></h1>
</span><span class="Keyword">discard</span><span class="Whitespace"> </span><span class="StringLit">&quot;c9&quot;</span><span class="Whitespace">
</span><span class="Comment"># also work after</span></pre>

</dd>
<a id="addfBug14485"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#addfBug14485"><span class="Identifier">addfBug14485</span></a><span class="Other">(</span><span class="Other">)</span> <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>

Some proc
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">discard</span><span class="Whitespace"> </span><span class="StringLit">&quot;foo() = &quot;</span><span class="Whitespace"> </span><span class="Operator">&amp;</span><span class="Whitespace"> </span><span class="Operator">$</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">]</span><span class="Whitespace">
</span><span class="LongComment">#[
0: let&apos;s also add some broken html to make sure this won&apos;t break in future
1: &lt;/span&gt;
2: &lt;/span&gt;
3: &lt;/span
4: &lt;/script&gt;
5: &lt;/script
6: &lt;/script
7: end of broken html
]#</span></pre>

</dd>

</dl></div>
Expand Down
1 change: 1 addition & 0 deletions nimdoc/testproject/expected/testproject.idx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ z13 testproject.html#z13 testproject: z13()
baz testproject.html#baz testproject: baz()
z17 testproject.html#z17 testproject: z17()
p1 testproject.html#p1 testproject: p1()
addfBug14485 testproject.html#addfBug14485 testproject: addfBug14485()
bar testproject.html#bar.m testproject: bar(): untyped
z16 testproject.html#z16.m testproject: z16()
z18 testproject.html#z18.m testproject: z18(): int
Expand Down
4 changes: 4 additions & 0 deletions nimdoc/testproject/expected/theindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ <h1 class="title">Index</h1>
<li><a class="reference external"
data-doc-search-tag="testproject: A" href="testproject.html#A">testproject: A</a></li>
</ul></dd>
<dt><a name="addfBug14485" href="#addfBug14485"><span>addfBug14485:</span></a></dt><dd><ul class="simple">
<li><a class="reference external"
data-doc-search-tag="testproject: addfBug14485()" href="testproject.html#addfBug14485">testproject: addfBug14485()</a></li>
</ul></dd>
<dt><a name="aEnum" href="#aEnum"><span>aEnum:</span></a></dt><dd><ul class="simple">
<li><a class="reference external"
data-doc-search-tag="utils: aEnum(): untyped" href="subdir/subdir_b/utils.html#aEnum.t">utils: aEnum(): untyped</a></li>
Expand Down
16 changes: 16 additions & 0 deletions nimdoc/testproject/testproject.nim
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@ when true: # capture non-doc comments correctly even before 1st token
# also work after
# this should be out

when true: # issue #14485
proc addfBug14485*() =
## Some proc
runnableExamples:
discard "foo() = " & $[1]
#[
0: let's also add some broken html to make sure this won't break in future
1: </span>
2: </span>
3: </span
4: </script>
5: </script
6: </script
7: end of broken html
]#

when true: # (most) macros
macro bar*(): untyped =
result = newStmtList()
Expand Down

0 comments on commit 579456d

Please sign in to comment.