recipe-tmlanguage 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,14 +7,15 @@ TextMate grammar for the [recipe] pharmacological notation language,
7
7
  **generated** from the same JavaScript vocabulary modules that drive
8
8
  `tree-sitter-recipe`'s parser.
9
9
 
10
- Ships as `dist/recipe.tmLanguage.json` for consumption by Shiki, VS Code,
11
- Sublime Text, Atom, `vscode-textmate`, and anything else that speaks
12
- TextMate.
10
+ Ships as `recipe.tmLanguage.json` (the package's main export) load it in
11
+ Shiki, a VS Code language extension, Monaco (via `monaco-textmate`), or any
12
+ other `vscode-textmate` host.
13
13
 
14
14
  ## Why generate, not author
15
15
 
16
- The parser's vocabulary (`FREQUENCY`, `TIMING`, `ROUTE`, …, `UNITS`) lives in
17
- plain `readonly string[]` modules under
16
+ The parser's vocabulary (`FREQUENCY`, `TIMING`, `ROUTE`, …, `UNITS`, plus the
17
+ Dutch patient-prose frequency vocab in `grammar/dutch`) lives in plain
18
+ `readonly string[]` modules under
18
19
  `tree-sitter-recipe/grammar/`. Authoring a parallel TextMate grammar by hand
19
20
  would mean copying those lists into regex alternations and re-copying them
20
21
  every time the parser is touched. Drift guaranteed.
@@ -56,22 +57,32 @@ grammar.
56
57
 
57
58
  ```text
58
59
  recipe-tmlanguage/
59
- ├── cli.ts # DreamCLI entry — `recipe-tmlang generate|verify`
60
+ ├── bin/
61
+ │ └── recipe-tmlang.ts # DreamCLI entry — `recipe-tmlang generate|verify`
60
62
  ├── src/
61
- │ ├── grammar.ts # pure: vocab → TextMate grammar object
62
- │ └── verifier.ts # pure: tokenize fixtures, check scope assertions
63
- └── dist/
64
- └── recipe.tmLanguage.json
63
+ │ ├── grammar.ts # pure: vocab → TextMate grammar object
64
+ │ └── verifier.ts # pure: tokenize fixtures, check scope assertions
65
+ ├── recipe.tmLanguage.json # generated grammar (the main export)
66
+ └── recipe.tmLanguage.ts # typed re-export of the JSON
65
67
  ```
66
68
 
67
- ## Setup
69
+ ## Install
68
70
 
69
- `tree-sitter-recipe` is pulled in via Bun's link mechanism. Run once in the
70
- sibling repo, then link here:
71
+ ```sh
72
+ bun add recipe-tmlanguage # or: npm install recipe-tmlanguage
73
+ ```
74
+
75
+ The grammar is pre-generated in the package — no build step for consumers.
76
+
77
+ ## Develop
78
+
79
+ `tree-sitter-recipe` is a regular npm dependency now, so a plain install is
80
+ all the setup there is:
71
81
 
72
82
  ```sh
73
- cd ../tree-sitter-recipe && bun link
74
- cd ../recipe-tmlanguage && bun link tree-sitter-recipe && bun install
83
+ bun install
84
+ bun run generate # rebuild recipe.tmLanguage.json
85
+ bun run verify # check scopes against the upstream fixtures
75
86
  ```
76
87
 
77
88
  ## CLI
@@ -79,16 +90,16 @@ cd ../recipe-tmlanguage && bun link tree-sitter-recipe && bun install
79
90
  Powered by [DreamCLI][dreamcli] — no hand-rolled argparse.
80
91
 
81
92
  ```sh
82
- bun cli.ts --help
93
+ npx recipe-tmlanguage --help # or: bunx recipe-tmlanguage --help
83
94
  ```
84
95
 
85
96
  ### `generate`
86
97
 
87
98
  ```sh
88
- bun cli.ts generate # → dist/recipe.tmLanguage.json
89
- bun cli.ts generate --out foo.json # custom path
90
- bun cli.ts generate --indent 2 --quiet # 2-space indent, silent
91
- bun cli.ts generate --json # machine-readable result on stdout
99
+ npx recipe-tmlanguage generate # → recipe.tmLanguage.json
100
+ npx recipe-tmlanguage generate --out foo.json # custom path
101
+ npx recipe-tmlanguage generate --indent 2 --quiet # 2-space indent, silent
102
+ npx recipe-tmlanguage generate --json # machine-readable on stdout
92
103
  ```
93
104
 
94
105
  ### `verify`
@@ -100,34 +111,23 @@ Fixtures and the Oniguruma WASM are located via package `exports` — no
100
111
  relative paths to maintain.
101
112
 
102
113
  ```sh
103
- bun cli.ts verify
104
- bun cli.ts verify --json # { pass, total, failures[] }
105
- bun cli.ts verify --max-failures 0 # print every failure
114
+ npx recipe-tmlanguage verify
115
+ npx recipe-tmlanguage verify --json # { pass, total, failures[] }
116
+ npx recipe-tmlanguage verify --max-failures 0 # print every failure
106
117
  ```
107
118
 
108
- Current status: **148 / 149** fixture assertions pass. The single failing
109
- assertion (`expanded.recipe:22:23`) points one column past the end of a
110
- 23-character source line — a fixture off-by-one, not a grammar defect.
111
-
112
- ### Drop into Shiki
119
+ Current status: **149 / 149** fixture assertions pass.
113
120
 
114
- ```ts
115
- import grammar from "recipe-tmlanguage/dist/recipe.tmLanguage.json";
116
- import { createHighlighter } from "shiki";
121
+ ### Use with Shiki
117
122
 
118
- const shiki = await createHighlighter({
119
- themes: ["github-dark"],
120
- langs: [grammar],
121
- });
122
-
123
- const html = shiki.codeToHtml(source, {
124
- lang: "recipe",
125
- theme: "github-dark",
126
- });
127
- ```
123
+ Don't register the raw JSON yourself — its grammar name is `Recipe`, which
124
+ won't match a `lang: "recipe"` lookup. Reach for [`recipe-shiki`][recipe-shiki]
125
+ instead: it wraps this grammar in a `LanguageRegistration` with the canonical
126
+ lang `recipe` (and alias `rx`).
128
127
 
129
- The scope names are standard TextMate, so any Shiki theme paints recipe
130
- blocks immediately.
128
+ For any other `vscode-textmate` host, load `recipe.tmLanguage.json` directly
129
+ grammar name `Recipe`, scope `source.recipe`. The scopes are standard TextMate,
130
+ so any theme paints recipe blocks immediately.
131
131
 
132
132
  ## License
133
133
 
@@ -138,5 +138,6 @@ blocks immediately.
138
138
  [jsr]: https://jsr.io/@kjanat/recipe-tmlanguage
139
139
  [npm]: https://npm.im/recipe-tmlanguage
140
140
  [recipe]: https://github.com/kjanat/tree-sitter-recipe
141
+ [recipe-shiki]: https://github.com/kjanat/recipe-shiki
141
142
 
142
143
  <!-- markdownlint-disable-file no-hard-tabs -->
@@ -21,9 +21,8 @@ import type { Out } from "dreamcli";
21
21
  import { buildGrammar, serializeGrammar } from "#grammar";
22
22
  import { verify } from "#verifier";
23
23
 
24
- import pkg from "#pkg" with { type: "json" };
24
+ import { homepage, repository, version } from "#pkg" with { type: "json" };
25
25
 
26
- const { homepage, repository, version } = pkg;
27
26
  const DEFAULT_OUT = `${resolve(import.meta.dirname, "..")}/recipe.tmLanguage.json`;
28
27
 
29
28
  const TS_RX_DIR = resolve(dirname(fileURLToPath(import.meta.resolve("tree-sitter-recipe/package.json"))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recipe-tmlanguage",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "TextMate grammar for the recipe (.recipe) pharmacological notation language.",
5
5
  "keywords": [
6
6
  "dreamcli",
@@ -27,14 +27,11 @@
27
27
  },
28
28
  "exports": {
29
29
  ".": "./recipe.tmLanguage.json",
30
- "./dist/*": "./dist/*",
31
30
  "./package.json": "./package.json"
32
31
  },
33
32
  "main": "./recipe.tmLanguage.json",
34
33
  "module": "./recipe.tmLanguage.json",
35
- "bin": {
36
- "recipe-tmlang": "bin/recipe-tmlang.ts"
37
- },
34
+ "bin": "bin/recipe-tmlang.mjs",
38
35
  "directories": {
39
36
  "lib": "/src",
40
37
  "bin": "/bin"
@@ -48,12 +45,13 @@
48
45
  "/LICENSE"
49
46
  ],
50
47
  "scripts": {
48
+ "bundle": "tsdown",
51
49
  "check": "biome check",
52
50
  "cli": "run recipe-tmlang",
53
51
  "fmt": "dprint fmt",
54
52
  "generate": "run recipe-tmlang generate",
55
53
  "lint": "biome lint",
56
- "prepack": "bun generate",
54
+ "prepack": "bun run generate && bun run bundle",
57
55
  "recipe-tmlang": "bun bin/recipe-tmlang.ts",
58
56
  "typecheck": "tsc --noEmit",
59
57
  "verify": "run recipe-tmlang verify"
@@ -69,6 +67,7 @@
69
67
  "@types/bun": "^1.3.14",
70
68
  "dprint": "^0.54.0",
71
69
  "runner-run": "^0.14.3",
70
+ "tsdown": "^0.22.3",
72
71
  "typescript": "^6.0.3"
73
72
  },
74
73
  "packageManager": "bun@1.3.14",