Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1244 from AndrejMitrovic/Fix7656
[ddoc] Issue 7656 and 7715 - ddoc must escape special characters
  • Loading branch information
Don Clugston committed Dec 6, 2012
2 parents 7910e8d + 06c24c8 commit ab5258d
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/doc.c
Expand Up @@ -2207,6 +2207,9 @@ void highlightCode2(Scope *sc, Dsymbol *s, OutBuffer *buf, size_t offset)
unsigned char *lastp = buf->data;
const char *highlight;

// let things like: string s = "$1$2 $ $4";
escapeDdocString(buf, 0);

//printf("highlightCode2('%.*s')\n", buf->offset - 1, buf->data);
res.reserve(buf->offset);
while (1)
Expand Down
13 changes: 13 additions & 0 deletions test/compilable/ddoc7656.d
@@ -0,0 +1,13 @@
// PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Ddtest_results/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 7656

module ddoc7656;

/**
--------
int x; // This is a $ comment (and here is some
int y; // more information about that comment)
--------
*/
void main() { }
16 changes: 16 additions & 0 deletions test/compilable/ddoc7715.d
@@ -0,0 +1,16 @@
// PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Ddtest_results/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 7715

module ddoc7656;

/**
$1 $2
---
string s = "$1$2 $ $4";
---
*/
void foo(){}

///
void test(string a = ")") {}
18 changes: 18 additions & 0 deletions test/compilable/extra-files/ddoc7656.html
@@ -0,0 +1,18 @@
<html><head>
<META http-equiv="content-type" content="text/html; charset=utf-8">
<title>ddoc7656</title>
</head><body>
<h1>ddoc7656</h1>
<br><br>
<dl><dt><big><a name="main"></a>void <u>main</u>();
</big></dt>
<dd><pre class="d_code"><font color=blue>int</font> x; <font color=green>// This is a $ comment (and here is some
</font><font color=blue>int</font> y; <font color=green>// more information about that comment)
</font></pre>
<br><br>

</dd>
</dl>

<hr><small>Page generated by <a href="http://www.digitalmars.com/d/2.0/ddoc.html">Ddoc</a>. </small>
</body></html>
22 changes: 22 additions & 0 deletions test/compilable/extra-files/ddoc7715.html
@@ -0,0 +1,22 @@
<html><head>
<META http-equiv="content-type" content="text/html; charset=utf-8">
<title>ddoc7656</title>
</head><body>
<h1>ddoc7656</h1>
<br><br>
<dl><dt><big><a name="foo"></a>void <u>foo</u>();
</big></dt>
<dd>&#36;1 &#36;2
<pre class="d_code">string s = <font color=red>"$1$2 $ &amp;#36;4"</font>;
</pre>
<br><br>

</dd>
<dt><big><a name="test"></a>void <u>test</u>(string <i>a</i> = ")");
</big></dt>
<dd><br><br>
</dd>
</dl>

<hr><small>Page generated by <a href="http://www.digitalmars.com/d/2.0/ddoc.html">Ddoc</a>. </small>
</body></html>

0 comments on commit ab5258d

Please sign in to comment.