Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix listblock preformatted overlap #4055

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions inc/Parsing/Lexer/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ public function parse($raw)
if ($currentLength === $length) {
return false;
}
// If we are closing a block and the last character consumed by our matched
// string is a newline, put it back. See the following for details:
// https://github.com/dokuwiki/dokuwiki/issues/4054
if ($this->isModeEnd($mode) && str_ends_with($matched, "\n")) {
$raw = "\n" . $raw;
$currentLength++;
}
$length = $currentLength;
$pos = $initialLength - $currentLength;
}
Expand Down
4 changes: 2 additions & 2 deletions inc/Parsing/ParserMode/Preformatted.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public function connectTo($mode)
$this->Lexer->addEntryPattern('\n\t(?![\*\-])', $mode, 'preformatted');

// How to effect a sub pattern with the Lexer!
$this->Lexer->addPattern('\n ', 'preformatted');
$this->Lexer->addPattern('\n\t', 'preformatted');
$this->Lexer->addPattern('\n (?![\*\-])', 'preformatted');
$this->Lexer->addPattern('\n\t(?![\*\-])', 'preformatted');
}

/** @inheritdoc */
Expand Down