Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixing bug where indented table header was seen as a dl#165

Merged
greg0ire merged 1 commit into
doctrine:0.4.xfrom
weaverryan:table-indented-header
Oct 17, 2021
Merged

Fixing bug where indented table header was seen as a dl#165
greg0ire merged 1 commit into
doctrine:0.4.xfrom
weaverryan:table-indented-header

Conversation

@weaverryan
Copy link
Copy Markdown
Collaborator

Hi!

We found this small bug from the Symfony documentation. If a simple table's header started with a space:

======  ===== =====
 Col A  Col B Col C
======  ===== =====
Col X   Col Y Col Z
------  ----- -----
Col U   Col J Col K
======  ===== =====

Then the entire structure was seen as a definition list, instead of a table. The fix is pretty logical: we check FIRST if the top line (e.g. ===== ===== ====) is a valid "table separator". And only if it is NOT, we then check to see if the next line (e.g. COL A COL B COL C) is indented to trigger a definition list.

Cheers!

@greg0ire greg0ire added the Bug Something isn't working label Oct 17, 2021
@greg0ire greg0ire merged commit f86b086 into doctrine:0.4.x Oct 17, 2021
@greg0ire greg0ire added this to the 0.4.4 milestone Oct 17, 2021
@greg0ire
Copy link
Copy Markdown
Member

Thanks @weaverryan !

$this->buffer->push($line);

return true;
} else {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be more logical if we slightly reorganize these nested if statements?

} elseif ($separatorLineConfig = $this->tableParser->parseTableSeparatorLine($line)) {
    $this->setState(State::TABLE);

    $tableNode = $this->nodeFactory->createTableNode(
    // ... (from line 313)
} elseif ($this->lineChecker->isIndented($this->lines->getNextLine())) {
    $this->setState(State::DEFINITION_LIST);

    // ... (from line 291)
} elseif ($this->getCurrentDirective() !== null && ! $this->getCurrentDirective()->appliesToNonBlockContent()) {
    // ... (from line 298)
} else {
    $this->setState(State::NORMAL);

    return false;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost definitely :). Please propose if if you have a vision - I'm a big fan of incrementally tweaking this library simply in order to make the code more understandable

@weaverryan weaverryan deleted the table-indented-header branch October 20, 2021 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants