Skip to content

Commit

Permalink
Fix Issue 12745 - [Ddoc] Underscore is removed from numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
ntrel committed Jul 30, 2014
1 parent ecb09de commit 841d62b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/doc.c
Expand Up @@ -2440,7 +2440,7 @@ void highlightText(Scope *sc, Dsymbol *s, OutBuffer *buf, size_t offset)
}

// leading '_' means no highlight unless it's a reserved symbol name
if (buf->data[i] == '_' &&
if (buf->data[i] == '_' && (i == 0 || !isdigit(buf->data[i-1])) &&
(i == buf->size-1 || !isReservedName((utf8_t *)(buf->data + i), j - i)))
{
buf->remove(i, 1);
Expand Down
20 changes: 20 additions & 0 deletions test/compilable/ddoc12745.d
@@ -0,0 +1,20 @@
// EXTRA_SOURCES:
// PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 12745

/**
i underlined $(BR)
_i not underlined $(BR)
__i force underscore $(BR)
$(BR)
_0 not underscored $(BR)
__0 force underscored
Underscores:
1_1 $(BR)
1_a $(BR)
a_1 $(BR)
a_a $(BR)
*/
int i;
26 changes: 26 additions & 0 deletions test/compilable/extra-files/ddoc12745.html
@@ -0,0 +1,26 @@
<html><head>
<META http-equiv="content-type" content="text/html; charset=utf-8">
<title>ddoc12745</title>
</head><body>
<h1>ddoc12745</h1>
<br><br>
<dl><dt><big><a name="i"></a>int <u>i</u>;
</big></dt>
<dd><u>i</u> underlined <br>
i not underlined <br>
_i force underscore <br>
<br>
0 not underscored <br>
_0 force underscored
<br><br>
<b>Underscores:</b><br>
1_1 <br>
1_a <br>
a_1 <br>
a_a <br><br><br>

</dd>
</dl>

<hr><small>Page generated by <a href="http://dlang.org/ddoc.html">Ddoc</a>. </small>
</body></html>

0 comments on commit 841d62b

Please sign in to comment.