Permalink
Browse files

Merge pull request #1244 from AndrejMitrovic/Fix7656

[ddoc] Issue 7656 and 7715 - ddoc must escape special characters
  • Loading branch information...
2 parents 7910e8d + 06c24c8 commit ab5258d5bcedc55dbfeeb0fb4cc4d283f184c7fd @donc donc committed Dec 6, 2012
View
3 src/doc.c
@@ -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)
View
13 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() { }
View
16 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 = ")") {}
View
18 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>
View
22 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.