When opening a Markdown document in Kate, invalid code inside code fences causes improper formatting of text after the end of the code fence. STEPS TO REPRODUCE 1. Create a file with the following text, not including the `----` markers: ---- # Invalid code sample ```php $foobar = "Foo bar"; ``` # This is another heading This is another nice line of text. ---- 2. Save as demo.md 3. Note formatting, specifically consistent colours on heading lines. 4. Remove one of the double quote characters from the string assignment line. OBSERVED RESULT Formatting of text after closing code fence is changed. EXPECTED RESULT Formatting of text after closing code fence should not change. No matter how bad the code inside the fences is, it should not affect the formatting of text outside the fences. This is especially important when opening a file specifically used to document invalid code. KDE Plasma Version: 5.18.5 KDE Frameworks Version: 5.68.0 Qt Version: 5.12.8
Created attachment 141309 [details] Kate 19.12.3 in Linuxmint showing correct highlighting Thanks for the bug report! I cannot reproduce the issue, neither with Kate from master nor with Kate 19.12.3 from a linuxmint 20.2 live usb. I have attached a screenshot of how it looks on both versions (minus differences on the colors), and similar highlighting happens in VS Code and Notepad++. Please attach a screenshot of the issue you described, even better if you point out the exact problem, so that we can check if it has already been fixed in newer versions.
setting to needsinfo
Thank you Jan. Notice this additional step needed to make the PHP code invalid, and thus break the Kate formatting: > 4. Remove one of the double quote characters from the string assignment line. Screenshot in a few minutes.
Created attachment 141326 [details] Good PHP code on the left, invalid PHP code on the right.
Note in the screenshot, the PHP code on the right is missing a double-quote character, making the code not valid PHP code.
Ahh, my bad. I don't know how I didn't notice the 4th step before, but now I can confirm that the bug exists in kate master. Takes for the quick response, complete with comparison screenshots!
Created attachment 141327 [details] SQL in a PHP block This is another example, in which valid SQL is mentioned in a PHP block. It breaks the formatting outside the code fences as well.
(In reply to Dotan Cohen from comment #7) > Created attachment 141327 [details] > SQL in a PHP block > > This is another example, in which valid SQL is mentioned in a PHP block. It > breaks the formatting outside the code fences as well. This one I can reproduce in Kate 19.12.3, but not anymore in the latest version from master. As for the original bug (the one with the unfinished string), that would be a bit tricky to fix as the php syntax-highlighting is "imported" wholesale, and current syntax rules dictate that a string in php will not end unless a closing " is supplied. It might take while for the bug to be fixed
I see, thank you.
Created attachment 185000 [details] PHP with `?>` breaking Markdown fenced code block I don't know if it's related or not, but when I write Markdown in Kate and put a fenced PHP code block, the closing fence is treated as a new opening fence if the fenced PHP code contains a `<?php […] ?>`. I've attached a screenshot of how I discovered it.