Fix cell detection broken by DokuWiki Mort's lexer anchor change - #23
Open
gh189 wants to merge 1 commit into
Open
Fix cell detection broken by DokuWiki Mort's lexer anchor change#23gh189 wants to merge 1 commit into
gh189 wants to merge 1 commit into
Conversation
DokuWiki's Mort release (2026-07-14) changed how the parser lexer matches special patterns: it now matches against the full document with a real byte offset instead of a cursor-relative substring, so a bare '^' anchor only matches a true line start (right after a literal "\n"), per normal PCRE multiline semantics. cellbg's trigger pattern used '^@...' relying on the old cursor-relative behaviour, where '^' effectively meant "wherever the lexer cursor currently is" -- which let it match right after the '|' delimiter that opens a table cell, even though that position is mid-line, not a real line start. With Mort's stricter/correct anchor semantics, '@color:' inside a table cell is never preceded by a literal newline, so the special pattern never matches, handle()/render() are never invoked, and the marker is emitted as literal text instead of turning into a bgcolor attribute. Fix: replace the '^' anchor with a bounded-width lookbehind for the preceding table delimiter ('|' or '^', optionally followed by spaces or tabs), which matches at the same effective position under both the old and the new lexer. Verified against the dokuwiki-2026-07-14 (Mort) release: all example cells from the plugin's documentation (solid color, hex color, default color, colors on non-first cells) now render with the correct bgcolor attribute again.
|
The fix doesn't work for me. I now get "A PCRE internal error occured. This might be caused by a faulty plugin" when I try to load a page. And the markup of the page has been converted to text only. Don't see any errors in the nginx log. This seems to be a bit of an old plugin.. don't think it will be fixed properly? are there any alternatives to change the colors in a table? |
|
It might be an issue with the PCRE version on ubuntu 24.04 This should probably be fine in ubuntu 26.04. But I wait to upgrade to that version until 26.04.1 is released (scheduled August 27, 2026) |
|
I also had same PCRE error This is working for me After editing page and saving it again Replacement syntax.php |
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since DokuWiki release 2026-07-14 "Mort", cellbg stops setting cell background colors —
@color:markers in table cells are rendered as literal text instead of being converted to abgcolorattribute.Root cause
connectTo()registers the trigger pattern:'^@#?[0-9a-zA-Z]*:(?=[^\n]*\|[[:space:]]*\n)'The leading
^was relying on an old lexer implementation detail: DokuWiki'sParallelRegex::split()used to match patterns against only the remaining unparsed substring, so^effectively matched "wherever the parser cursor currently is" — which happened to be right after the|that opens a table cell, even though that's mid-line, not a real line start.Mort's parser/lexer rewrite (needed to correctly support lookbehind assertions for the new GFM emphasis/closer engine) changed
ParallelRegex::split()to match against the full document with a real byte offset viaPREG_OFFSET_CAPTURE. Under normal PCRE multiline semantics,^now only matches right after a literal\n(or at the very start of the document). Since@color:inside a table cell always follows a literal|/^delimiter on the same source line,^no longer matches there, the special pattern is never triggered, andhandle()/render()are never called for it.I reproduced this against the actual
dokuwiki-2026-07-14release tarball and confirmed:@red:test|as the very first line of a document → still matches (real line start).| @lightgreen:**Span** | ... |) → never matches anymore.Fix
Replace the
^anchor with a bounded-width lookbehind for the actual preceding table delimiter (|or^, optionally followed by spaces/tabs). This matches at the same effective position under both the old cursor-relative lexer and Mort's full-document/offset-based lexer, so it works across DokuWiki versions:'(?<=[|^][\t ]{0,20})@#?[0-9a-zA-Z]*:(?=[^\n]*\|[[:space:]]*\n)'Testing
Verified against the real
dokuwiki-2026-07-14"Mort" release (viabin/render.php) using all the example tables from the plugin's documentation page (solid color name, hex color, default@:color, and colors on non-first cells) — all now render with the correctbgcolorattribute again. Also confirmed no regression for the plain-first-line-of-document case.