Skip to content

Commit

Permalink
[BUGFIX] Multiline comments may contain empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf authored and jaapio committed Mar 2, 2024
1 parent 3aa4eb9 commit 5af7e1c
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ private function isCommentLine(string|null $line): bool
return false;
}

return $this->isComment($line) || (trim($line) !== '' && $line[0] === ' ');
return $this->isComment($line) || trim($line) === '' || $line[0] === ' ';
}

private function isComment(string $line): bool
{
return trim($line) === '..' || preg_match('/^\.\.\s+.*$/mUsi', $line) > 0;
return trim($line) === '..' || preg_match('/^\.\.\s+[^:]*$/mUsi', $line) > 0;
}
}
3 changes: 0 additions & 3 deletions tests/Functional/tests/comment-empty/comment-empty.html
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<p>this is not a comment</p>
<blockquote>
<p>this is a blockquote</p>
</blockquote>
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ <h1>Document title</h1>
<p>A note without a class</p>
</div>

<blockquote class="highlights"><p>Block quote text.</p></blockquote>

</div>

<!-- content end -->
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ Document title

..
Block quote text.
This is a comment
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- content start -->
<div class="section" id="some-title">
<h1>Some Title</h1>

<p>This text is no comment</p>
</div>

<!-- content end -->
10 changes: 10 additions & 0 deletions tests/Integration/tests/comments/comment-multiline/input/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Some Title
==========

..
This whole indented block
is a comment.
Still in the comment.

This text is no comment
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- content start -->
<div class="section" id="some-title">
<h1>Some Title</h1>

<div class="admonition note">
<p>No comment!</p><p>This text is no comment</p>
</div>

<p>After the node</p>
</div>

<!-- content end -->
15 changes: 15 additions & 0 deletions tests/Integration/tests/comments/comment-nested/input/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Some Title
==========

.. note::
No comment!

..
This whole indented block
is a comment.
Still in the comment.

This text is no comment

After the node

0 comments on commit 5af7e1c

Please sign in to comment.