Bug 500809

Summary: Apostrophe in text breaks highlighting of YAML markup
Product: [Frameworks and Libraries] frameworks-syntax-highlighting Reporter: daobrien
Component: syntaxAssignee: KWrite Developers <kwrite-bugs-null>
Status: REPORTED ---    
Severity: normal CC: christoph, john.kizer, walter.von.entferndt
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description daobrien 2025-02-27 11:18:23 UTC
SUMMARY
The use of an apostrophe in a string inside an array causes the syntax highlighting to fail from the apostrophe to the end of the file. If I double quote the string the problem doesn't occur. Problem does not occur if I use a backtick.

STEPS TO REPRODUCE
1. Create a simple YAML file and ensure the file type is set to "markup:yaml".
2. Create a key in a YAML file that takes its values from an array.
3. Enter a string that contains an apostrophe in the array.

OBSERVED RESULT

From the apostrophe to the end of the file syntax highlighting no longer works.

EXPECTED RESULT

Syntax highlighting should not fail.

SOFTWARE/OS VERSIONS
Fedora 41
GNOME Shell 47.4
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION

Example entry that fails:
editors: [David O'Brien]

Example entry that does not fail:
editors: ["David O'Brien"]
Comment 1 Christoph Cullmann 2025-03-01 19:58:46 UTC
https://yaml.org/spec/1.2.2/#single-quoted-style

Is that not just a side effect on ' starting a single quoted string?
Comment 2 John Kizer 2025-03-16 03:10:05 UTC
Hi - just changing status here as this appears to be pending a response, thanks!
Comment 3 daobrien 2025-03-17 06:42:41 UTC
(In reply to Christoph Cullmann from comment #1)
> https://yaml.org/spec/1.2.2/#single-quoted-style
> 
> Is that not just a side effect on ' starting a single quoted string?

tbh I don't know. If this falls under the heading of "expected behaviour" then ok, but it took me by surprise. I currently get around it by not using an array. Feel free to close this if you think it's not a bug.
cheers.