Skip to content

Commit

Permalink
Fix bugzilla issue 24871 - DDoc strips indent in triple slash comments
Browse files Browse the repository at this point in the history
Removes code in the lexer responsible for removing leading spaces in
triple slash doc comments.

This affects the test file for issue 14413; two more spaces appear, but
they are not significant in the HTML output.
  • Loading branch information
ArthaTi committed Nov 22, 2024
1 parent 3fa3ac8 commit 303d95f
Show file tree
Hide file tree
Showing 4 changed files with 599 additions and 9 deletions.
9 changes: 2 additions & 7 deletions compiler/src/dmd/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -3441,15 +3441,10 @@ class Lexer
if (*q != ct)
break;
}
/* Remove leading spaces until start of the comment
/* Remove leading line feed
*/
int linestart = 0;
if (ct == '/')
{
while (q < qend && (*q == ' ' || *q == '\t'))
++q;
}
else if (q < qend)
if (ct != '/' && q < qend)
{
if (*q == '\r')
{
Expand Down
19 changes: 19 additions & 0 deletions compiler/test/compilable/ddoc24871.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh
import std.stdio;

/// Example
/// ---
/// void main() {
/// foreach (i; 0..10) {
/// writeln("Hello, world!");
/// }
/// }
/// ---
void main() {

writeln("Hello, World!");

}

4 changes: 2 additions & 2 deletions compiler/test/compilable/extra-files/ddoc14413.html
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ <h4>Declaration</h4>
<div class="ddoc_summary">
<p class="para">
This should
be one
paragraph.
be one
paragraph.

</p>
</div>
Expand Down
Loading

0 comments on commit 303d95f

Please sign in to comment.