Skip to content

chore: scope subscript/superscript delimiters as punctuation.definition#21

Merged
paxcalpt merged 1 commit into
mainfrom
chore/subsup-delimiter-captures
May 29, 2026
Merged

chore: scope subscript/superscript delimiters as punctuation.definition#21
paxcalpt merged 1 commit into
mainfrom
chore/subsup-delimiter-captures

Conversation

@paxcalpt
Copy link
Copy Markdown
Contributor

Summary

Optional polish flagged (and deferred) in the #17 review: the ~ / ^ subscript/superscript delimiters now get their own punctuation.definition.{subscript,superscript}.{begin,end}.rxiv scopes via captures, consistent with how the existing markup.bold / markup.italic rules scope their delimiters. This lets themes style the delimiters independently of the content; the default appearance is unchanged.

Behaviour

Match behaviour is identical — only capture grouping was added. Verified the regexes still match H~2~O, CO~2~, E=mc^2^, x^n^ and still ignore ~~strikethrough~~ and [^1] footnotes.

Folds into the unreleased 0.3.17 CHANGELOG entry; no version bump.

🤖 Generated with Claude Code

Follow-up polish from the #17 review. The ~ / ^ delimiters now get their
own punctuation.definition.{subscript,superscript}.{begin,end}.rxiv scopes
via captures, consistent with the existing markup.bold / markup.italic
rules, so themes can style the delimiters independently of the content.

Match behaviour is unchanged: the regexes still match H~2~O, CO~2~,
E=mc^2^, x^n^ and still ignore ~~strikethrough~~ and [^1] footnotes. Folds
into the unreleased 0.3.17 entry (no version bump).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 29, 2026 19:40
@claude
Copy link
Copy Markdown

claude Bot commented May 29, 2026

Code Review — PR #21: Scope subscript/superscript delimiters as punctuation.definition

Overall: Clean, well-scoped change. Ready to merge with one minor observation.


What the PR does

Adds captures to the subscript (~) and superscript (^) grammar rules so their delimiter characters receive explicit TextMate scopes (punctuation.definition.subscript.begin.rxiv, etc.), consistent with how markup.bold and markup.italic already scope their delimiters.


Code quality

  • The regex changes are correct: wrapping each delimiter in its own capture group ((~)…(~) and (\^)…(\^)) while preserving the original match behaviour is exactly the right approach.
  • Scope naming (punctuation.definition.{subscript,superscript}.{begin,end}.rxiv) is consistent with the bold/italic convention and properly namespaced with .rxiv.
  • The CHANGELOG amendment (extending the existing 0.3.17 entry rather than adding a new one) is appropriate.

Minor observation: capture group 2 not explicitly scoped

The markup.bold/markup.italic rules explicitly assign the outer name to capture group 2 (the content):

"2": {"name": "markup.bold.markdown"}

The new subscript/superscript captures blocks omit group 2. This is functionally fine — the outer name on the rule already covers the entire match, so the content inherits markup.subscript.rxiv / markup.superscript.rxiv without needing an explicit capture. It's arguably cleaner than the bold/italic approach (which redundantly re-states the outer scope). Worth a one-line comment in the grammar if you want explicit parity, but not a blocker.


Verdict

No bugs, no performance concerns, no security issues. The change is minimal, correct, and consistent with existing conventions. ✅

@paxcalpt paxcalpt merged commit a356cf4 into main May 29, 2026
2 of 3 checks passed
@paxcalpt paxcalpt deleted the chore/subsup-delimiter-captures branch May 29, 2026 19:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Minor polish PR that adds delimiter capture groups to the ~subscript~ and ^superscript^ grammar rules so the ~/^ characters receive their own punctuation.definition.{subscript,superscript}.{begin,end}.rxiv scopes, matching the convention already used by the bold, italic, raw, and math rules. Match behavior is unchanged; only capture grouping is added.

Changes:

  • Wrap the opening and closing delimiters in capture groups and add a captures block for the subscript and superscript grammar rules.
  • Extend the existing unreleased 0.3.17 CHANGELOG entry to mention the new delimiter scopes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
syntaxes/rxiv-markdown.tmLanguage.json Adds delimiter captures to subscript/superscript rules.
CHANGELOG.md Appends a note to the 0.3.17 entry about the new punctuation scopes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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