Skip to content

Commit

Permalink
Check if indented line is blank
Browse files Browse the repository at this point in the history
Definition list are composed by a term and a definition block. The term
and the definition block may not be separated by a blank line. Lines
with only whitespace are considered blank.
  • Loading branch information
greg0ire committed Jul 19, 2023
1 parent 06bc37c commit 3677db5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Parser/DocumentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private function parseLine(string $line): bool
return true;
}

if ($this->lineChecker->isIndented($this->lines->getNextLine())) {
if (trim($this->lines->getNextLine()) !== '' && $this->lineChecker->isIndented($this->lines->getNextLine())) {
$this->setState(State::DEFINITION_LIST);
$this->buffer->push($line);

Expand Down
10 changes: 10 additions & 0 deletions tests/Functional/tests/render/definition-list/definition-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,13 @@ <h1>
</dd>
</dl>
</div>
<div class="section" id="not-a-definition-list">
<h1>
Not a definition list
</h1>
<p>Single line followed by a blank line</p>
<blockquote>
<p>This line is indented, but because of the blank line, it should
not be considered a term. It is a blockquote.</p>
</blockquote>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,11 @@ term 1
.. note::

directive in definition list

Not a definition list
=====================

Single line followed by a blank line

This line is indented, but because of the blank line, it should
not be considered a term. It is a blockquote.

0 comments on commit 3677db5

Please sign in to comment.