Highlight only a step parameter's captured value; add built-in {emph} type#64
Conversation
…ot its surrounding notation
Editor highlighting painted the whole cucumber-expression parameter match
as a parameter token — including the delimiters, e.g. the quotes in
{string} matching "hi there". Only the inner value is passed to the step
handler, so only that should be highlighted.
The matcher now records each parameter's inner capture-group span
(paramInnerSpans) alongside the full-notation span, and the language index
uses it for paramRanges (semantic tokens and var/stepAt), which VS Code and
the website editor consume. paramValues keeps the full notation so rename
still splices values back verbatim. Parameters whose regexp has no capture
group ({int}, {word}, ...) fall back to highlighting the whole match.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KQvfYkzr57MdiM4Xh5hyvw
Markdown emphasis was something every project hand-rolled as a custom
parameter type. It is now a built-in `{emph}` in every port, matching all six
uniform emphasis notations — *x*, _x_, **x**, __x__, ***x***, ___x___ — and
passing only the inner text to the handler (only the outermost delimiter pair
is stripped, so **_x_** yields _x_). Editors highlight just that value.
Because it is a built-in, expressions can use `{emph}` with no declaration;
the example projects drop their bespoke emphasis parameter and use it directly.
It carries a format that renders a mismatch back as *value*.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KQvfYkzr57MdiM4Xh5hyvw
aslakhellesoy
left a comment
There was a problem hiding this comment.
See comments
| Assert.Empty(r.Steps); | ||
| Assert.NotNull(r.ParameterTypes.LookupByTypeName("int")); | ||
| Assert.NotNull(r.ParameterTypes.LookupByTypeName("string")); | ||
| // var's own built-in Markdown emphasis type. |
There was a problem hiding this comment.
var's? It should be Varar's.
Why do you still think this project is named Vár? We renamed it to Varar last week. Update your memory.
There was a problem hiding this comment.
Fixed — renamed var → Varar in the comments this branch added, across every port (pushed in 66b5c2b). A few older var references predate this branch (elsewhere in this file, and in the junit/kotlin sources this PR doesn't otherwise touch); I left those out to keep the diff scoped to the feature, but happy to do a dedicated repo-wide rename sweep as a follow-up if you'd like. (One note: I don't carry memory between sessions, so there's nothing durable for me to update — but the naming is corrected here.)
Generated by Claude Code
| format: (t) => `*${t}*`, // Emma → *Emma* (mismatch display) | ||
| tag: { | ||
| regexp: /#\w+/, | ||
| parse: (raw) => raw.slice(1), // #urgent → urgent |
There was a problem hiding this comment.
I think we should teach the reader about capture groups. If the regexp was written /#(\w+)/, we wouldn't need the slice.
There was a problem hiding this comment.
Good call — done. Both markup-is-yours.md and the custom-parameters reference now use /#(\w+)/ and drop the parse/slice, with a line explaining that the first capture group is the value the handler receives — and the exact span editors highlight (which ties into the highlight change in this PR). The reference's "no capture groups" guidance was updated to match. Pushed in 66b5c2b.
Generated by Claude Code
… Varar in comments Addresses PR review: - markup-is-yours.md and the custom-parameters reference now show a capture group (/#(\w+)/) as the way to pick out the value — the first capture group is what the handler receives and the span editors highlight — instead of slicing markers off in parse. - Renamed "var" to "Varar" in the comments this branch added across the ports. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KQvfYkzr57MdiM4Xh5hyvw
…aragraph (#65) Fixes #61. A multi-table example no longer relies on the "hug" — a step paragraph glued directly beneath a table with no blank line — which is not valid GFM and does not survive a Markdown formatter (prettier re-emits the step as a table row, silently changing what the spec means). Instead an example spans everything between two delimiters: a heading, a thematic break (---), or a paragraph that matches no step (prose). Consecutive matching paragraphs merge into one shared-state example, so a Given -> table -> When -> table -> Then flow is written as ordinary, formatter-stable Markdown with blank lines between the tables. Ported across all seven language ports with a new conformance bundle; drift detection now reports a step paragraph that a mid-example edit turned back into prose. Also removes the Gherkin/.feature compatibility layer and the generic scannerPlugins scanner-extension mechanism it was the only user of (feature creep): the gherkin table, doc-string, and keyword plugins, the @varar/cucumber package, the scannerPlugins config field and schema property, and all wiring across every port. To migrate a Cucumber suite, hand your .feature files to a coding agent and ask it to translate them into Markdown specs and Varar step definitions; the website's "Varar for Cucumber users" page maps each Gherkin-ism, including Scenario Outline -> header-bound table. BREAKING CHANGE: Two step-only examples separated by only a blank line now run as a single shared-state example — separate them with a `---` or a heading, and keep prose out of the middle of an example (a non-matching paragraph between steps ends the example). Additionally, Varar no longer runs Gherkin `.feature` files and the `scannerPlugins` config key has been removed (it is now an unknown-key error). Migrate `.feature` suites by translating them to Markdown specs and porting the step definitions. Claude-Session: https://claude.ai/code/session_01SqKahEdcXvVEYXt2zuYQwJ Co-authored-by: Aslak Hellesøy <aslak@oselvar.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ighlight-groups-ejextc # Conflicts: # dotnet/Varar.Tests/ConformanceFixtures.cs # go/conformance/conformance_test.go # java/kotlin/src/test/kotlin/dev/varar/kotlin/ConformanceTest.kt # java/varar/src/test/java/dev/varar/ConformanceTest.java # rust/varar/tests/conformance.rs # typescript/packages/core/src/plan.ts # typescript/packages/website/src/content/docs/explanation/markup-is-yours.md
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UvMopw64mP5HVoU2R9N3ew
Closes #
What this changes
Two related changes to how step parameters are treated.
1. Highlight only the captured value, not the surrounding notation (
fix(vscode), TS/LSP only).The LSP painted the whole cucumber-expression parameter match as a
parametersemantic token — for{string}that included the quotes ("hi there"), even though the handler only ever receiveshi there. Highlighting now covers only the value passed to the step function: the outermost inner capture group of the parameter's regexp.paramInnerSpans) alongside the full-notation span; the language index uses it forparamRanges(semantic tokens +var/stepAt), which VS Code and the website CodeMirror editor consume automatically.paramValuesstays sourced from the full-notation span, so rename is byte-for-byte unchanged (it splices values back verbatim; it never readsparamRanges).{int},{word}, …) fall back to highlighting the whole match.2. Built-in
{emph}parameter type for Markdown emphasis (feat(spec), all ports).Markdown emphasis was something projects hand-rolled as a custom parameter. It is now a built-in
{emph}in every port, matching all six uniform notations —*x*,_x_,**x**,__x__,***x***,___x___— and passing only the inner text to the handler (only the outermost delimiter pair is stripped, so**_x_**→_x_). It carries aformatthat renders a mismatch back as*value*. The example projects drop their bespoke emphasis parameter and use{emph}directly; a new conformance bundle (18-emphasis-parameter) pins it across all ports, and the docs are updated.The two compose:
{emph}uses inner capture groups exactly like{string}, so change 1 makes{emph}highlight its inner text automatically.How you verified it
typescript/):pnpm -r build,pnpm typecheck,pnpm lint,pnpm vitest run— all green (600 tests), including the new matcher/plan/index/handlers/emph tests and the regenerated conformance bundle 18 (existing goldens byte-identical).{emph}is seeded so it never appears inregistry.jsongoldens'parameterTypes.Note: this diff is agent-written and should be read before merge — the boxes below are for the submitting human to confirm.
🤖 Generated with Claude Code
Generated by Claude Code