Bug 15475 – Ddoc code sample with unbalanced paren comes out as macro

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-12-24T15:37:48Z
Last change time
2018-05-19T11:11:34Z
Keywords
pull
Assigned to
No Owner
Creator
Adam D. Ruppe

Comments

Comment #0 by destructionator — 2015-12-24T15:37:48Z
/** --- // code sample with unbalanced ( --- */ module t2; Spits out: <pre class="d_code"><font color=green>// code sample with unbalanced $(LPAREN) </font></pre> in the final code.
Comment #1 by hsteoh — 2016-03-08T18:25:14Z
Bumping this up to importance normal, because it's messing up std.random docs where there are a lot of unbalanced parens. This is really ridiculous. Ddoc should not touch stuff inside code blocks; the code should come out verbatim.
Comment #2 by destructionator — 2016-03-08T18:31:07Z
my doc generator handles this correctly just saying (my doc gen even handles `---` inside comments in the samples! it is fancy.)
Comment #3 by hsteoh — 2016-03-08T18:35:33Z
The problem is the doc.d right now is a fragile tangle of spaghetti code, full of special cases and unexpected gotchas, and changing one small thing may cause unrelated breakage elsewhere. It really needs to be refactored into something more maintainable. But it's so complex that such a refactoring would have to be done piecemeal, otherwise it would cause even more breakage.
Comment #4 by hsteoh — 2016-03-08T19:23:20Z
Found that the problem is that the ')' is doubly-escaped: by the time it gets to highlightText(), it's already escaped, but highlightText doesn't know that, and when it calls highlightCode2() it escapes it a second time, turning `$(RPAREN)` (which would have correctly expanded into ')') into `$(DOLLAR)$(LPAREN)RPAREN$(RPAREN)`, so it expands back to `$(PAREN)` instead.
Comment #5 by hsteoh — 2016-03-08T20:40:04Z
Comment #6 by github-bugzilla — 2016-03-09T05:37:08Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/70c53a536cd021fb7a1798dd0cc493056d6b6586 Issue 15475: ddoc should not escape unbalanced parens in code blocks. Add test case. https://github.com/D-Programming-Language/dmd/commit/03c6aeb26a93d5c7ab5e60c6c2284b8220044db9 Merge pull request #5507 from quickfur/issue15475 Issue 15475: ddoc should not escape unbalanced parens in code blocks twice.
Comment #7 by github-bugzilla — 2018-05-19T11:11:33Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/e0e23b7250401521c8db05c079ae2b59408afb0e Fix Issue 15475 - Fix more cases https://github.com/dlang/dmd/commit/843dbf3fa056a0a35b5c59c58a129ec65818b24d Merge pull request #8238 from dgileadi/ddoc-unbalanced-parens-in-code Fix more cases of bug 15475