Skip to content

feat(semantic): scope document-text cartouche bodies as documentation - #170

Merged
Arthur742Ramos merged 1 commit into
mainfrom
arthur742ramos/grammar-document-text
Jun 11, 2026
Merged

feat(semantic): scope document-text cartouche bodies as documentation#170
Arthur742Ramos merged 1 commit into
mainfrom
arthur742ramos/grammar-document-text

Conversation

@Arthur742Ramos

Copy link
Copy Markdown
Owner

What

Scopes the body of document-markup commands (chapter / section /
subsection / subsubsection / paragraph / subparagraph / text /
txt / text_raw) as documentation (comment-like) instead of a generic
cartouche string.

Why

text ‹…› and section headings are formal document prose; Isabelle/jEdit
renders them distinctly from inner-syntax cartouches. Colouring them as a plain
quoted string under-sells that distinction. This makes the editor read the way
the document model intends.

Behaviour

  • @{…} antiquotations, \<…> symbols, and nested cartouches inside the
    prose stay highlighted.
  • Plain cartouches elsewhere (definition … where ‹…›, inner-syntax terms)
    are unaffected — only doc-command bodies change.
  • Both Unicode ‹…› and ASCII \<open>…\<close> openers are handled.

How tested

  • Real vscode-textmate + vscode-oniguruma tokenization of
    section ‹Intro @{term x}›, text ‹… \<lambda> … ‹nested› …›,
    lemma foo: "…", and definition … where \<open>not doc\<close>
    doc bodies scope as comment.block.documentation, antiquotations/symbols
    remain highlighted, nesting is correct, and non-doc cartouches/strings are
    unchanged.
  • npm run check — 1226 tests pass (new structural assertion pins the patterns).
  • npm run bundle — clean.

The body of a document-markup command (chapter / section / subsection /
subsubsection / paragraph / subparagraph / text / txt / text_raw) is now scoped
as documentation (comment-like) instead of a generic cartouche string, so
`text ‹…›` and section headings render as prose — matching how Isabelle/jEdit
presents formal document text. Antiquotations, `\<…>` symbols, and nested
cartouches inside the prose stay highlighted; plain cartouches elsewhere are
unaffected.

Implemented as two grammar patterns (Unicode ‹…› and ASCII \<open>…\<close>) that
win over the generic cartouche by ordering. Verified end to end against the real
Oniguruma engine and pinned by a structural assertion in the grammar drift test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 11, 2026 04:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Isabelle TextMate grammar so that cartouche bodies of document-markup commands (e.g. section ‹…›, text \<open>…\<close>) are scoped as documentation (comment.block.documentation.isabelle) rather than as a generic cartouche string, making prose render more like Isabelle/jEdit while preserving nested highlighting (antiquotations, symbols, nested cartouches).

Changes:

  • Add dedicated documentation-unicode / documentation-ascii grammar rules and place them before the generic cartouche patterns.
  • Add/extend a drift-style grammar manifest test to assert repository entries exist, have the right scopes, and are ordered correctly.
  • Document the new highlighting behavior in CHANGELOG.md (currently needs a small fix—see comment).

Reviewed changes

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

File Description
syntaxes/isabelle.tmLanguage.json Adds documentation cartouche patterns and ensures they take precedence over generic cartouches.
test/syntaxes/isabelleGrammar.test.ts Extends grammar-manifest assertions to pin documentation scoping and pattern ordering.
CHANGELOG.md Notes the new document-text scoping behavior (but currently merges two bullets unintentionally).
Comments suppressed due to low confidence (1)

CHANGELOG.md:22

  • This changelog entry accidentally absorbs the next bullet’s content (the find_unused_assms/nunchaku/… list) into the new “Document-text reads as prose” item, because the diagnostic-commands bullet heading was removed but its continuation lines remain. This makes the “Added” section misleading and hard to read.
  cartouches elsewhere (e.g. `definition … where ‹…›`) are unaffected. Offline.
  `find_unused_assms`, `nunchaku`, `test_code`, the `print_bnfs` /
  `print_claset` / `print_induct_rules` / `print_coercions` / `print_record` /
  `print_case_translations` / `print_quotients` / `print_quotconsts` /
  `print_quot_maps` inspection commands, and the tool-configuration commands

@Arthur742Ramos
Arthur742Ramos merged commit e653ce4 into main Jun 11, 2026
3 checks passed
@Arthur742Ramos
Arthur742Ramos deleted the arthur742ramos/grammar-document-text branch June 11, 2026 04:46
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