Skip to content

fix: stop single-line string rules at line ends - #21

Merged
davatron5000 merged 2 commits into
davatron5000:mainfrom
danielroe:fix/single-line-strings
Sep 2, 2026
Merged

davatron5000 merged 2 commits into
davatron5000:mainfrom
danielroe:fix/single-line-strings

Conversation

@danielroe

Copy link
Copy Markdown
Contributor

What does this change?

I split this out from #18 for ease of reviewing

the context is something like some.css (which I was trying to highlight).

a single stray apostrophe highlights the rest of the file as a string. for example, in:

a { font-family: Don't; }
b { content: "kept"; }
c { font-family: Won't; }

everything from the ' in Don't to the one in Won't comes out as string, and similarly in yaml.

the issue was that single-line string rules didn't exclude line breaks. elsewhere, javascript.js and python.js already use [^"\\\r\n], and toml's single-quoted rule does too, so this adds the same behaviour to grammars that were missing it

(I've left alone the languages where a raw newline inside a quoted string is legal, assuming it was deliberate)

yaml does allow quoted scalars to fold over lines (I learned), but only onto more-indented ones, so I handle that case as well ...

and one more (unrelated) issue, which I'm happy to split out into further PR if you like: a number of block at-rules were missing and being highlighted as selectors.

happy to make any and all changes, or feel free to directly push changes 🙏

Checklist

  • npm test passes locally
  • The size budget still passes (note any size impact below)
  • Added/updated tests or the demo (docs/index.html) if behavior changed
  • For a new grammar/theme, followed the steps in CONTRIBUTING.md

Size impact

none

@davatron5000
davatron5000 merged commit 8375e1d into davatron5000:main Sep 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants