Skip to content

Editor: highlighting disagrees with the parser on nameless timers, mid-line comments and escapes #664

Closed

Description

@LeMyst

The editor's Cooklang mode (static/js/src/cooklang-mode.js, added in 42bcebb / #246) still highlights a few constructs differently from how cooklang 0.19 parses them. #663 fixes the block-comment closer (#494) and gives quantities a highlight tag (#495), but these remain:

Text Parser (cook recipe -f json) Editor
Stir-fry for ~{1%minute} (in seed/Thai Green Curry.cook, seed/lamb-chops.cook) timer, quantity 1, unit minute ~{ is the timer token, so 1 and minute get no colour; the new cm-cook-quantity from #663 never applies to nameless timers
Add @oil. -- careful [- not a block -- is a line comment anywhere on a line (lexer line_comment) -- is a comment only at the start of a line; the [- opens a block comment and every following line is shown as a comment
Season \[- not a comment \ escapes the next character the [- opens a block comment for the rest of the file
@salt -- or {3} / @pepper [- or {more} -] to taste ingredient salt / pepper without a quantity, the rest is a comment the name regex runs through the comment opener, so the comment is shown as part of the name and {3} / {more} as a quantity

Also:

  • state.position is never set to "timer", so the two "timer" checks in the brace handling are dead code.
  • cooklang-mode.js now imports Tag from @lezer/highlight (and editor.js already imported tags), but package.json doesn't declare it; it only arrives through @codemirror/language, whose range (^1.0.0) allows versions without Tag.define(name).

🤖 Analysis made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst.

Activity

  1. added a commit that references this issue on Oct 10, 2026
    2700d3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions