Check if indented line is blank

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.
This commit is contained in:
Grégoire Paris
2023-07-19 22:31:02 +02:00
parent 06bc37cc4c
commit 3677db5150
3 changed files with 19 additions and 1 deletions

View File

@@ -309,7 +309,7 @@ final class DocumentParser
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);

View File

@@ -94,3 +94,13 @@ definition 2 </dd>
</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>

View File

@@ -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.