Skip to content

Commit

Permalink
fix nim-lang#14485 ; workaround for strutils.addf bug
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed May 28, 2020
1 parent e013ebc commit 8a11f03
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions compiler/renderverbatim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,26 @@ proc renderNimCode*(result: var string, code: string, isLatex = false) =
buf.setLen 0
buf.addEscaped(val)
let class = tokenClassToStr[kind]

#[
xxx bug in strutils.addf: this crashes:
var ret: string
ret.addf "foo $1 bar" % ["$"]
]#
when false:
if isLatex:
result.addf "\\span$1{$2}" % [class, buf]
else:
result.addf "<span class=\"$1\">$2</span>" % [class, buf]

if isLatex:
result.addf "\\span$1{$2}" % [class, buf]
result.addf "\\span$1{" % [class]
result.add buf
result.add "}"
else:
result.addf "<span class=\"$1\">$2</span>" % [class, buf]
result.addf "<span class=\"$1\">" % [class]
result.add buf
result.add buf "</span>"

while true:
getNextToken(toknizr, langNim)
Expand Down

0 comments on commit 8a11f03

Please sign in to comment.