nattoppet 4.1.0 → 4.1.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/GUIDE.md CHANGED
@@ -194,7 +194,8 @@ A mixin inlines another file into the current token stream.
194
194
  - If the path has an extension, it is used as-is.
195
195
  - If the path has no extension and a file with that exact name exists, it is used.
196
196
  - Otherwise, `.ymd` is appended (e.g. `[mixin] common` resolves to `common.ymd`).
197
- - **All mixin paths are resolved relative to the nattoppet installation directory** (where `compiler.ts` lives). Paths starting with `./` are **not** treated specially; they also resolve relative to the compiler root.
197
+ - Bare paths such as `common` resolve relative to the nattoppet installation directory.
198
+ - Explicit relative paths beginning with `./` or `../` resolve relative to the input document. Relative paths inside a mixin resolve relative to that mixin.
198
199
 
199
200
  ### Non-`.ymd` mixins
200
201
 
@@ -213,7 +214,7 @@ A mixin can contain a `[#slot]` marker. When the mixin is expanded, the caller's
213
214
  [#slot]
214
215
 
215
216
  [#] -- page.ymd --
216
- [mixin] layout.ymd
217
+ [mixin] ./layout.ymd
217
218
 
218
219
  [title]: My Page
219
220
  <h1>Hello</h1>
@@ -223,7 +224,7 @@ A mixin can contain a `[#slot]` marker. When the mixin is expanded, the caller's
223
224
 
224
225
  ### `common.ymd`
225
226
 
226
- `common.ymd` ships with nattoppet in the project root. Since mixin paths resolve relative to the compiler root, `[mixin] common` finds it automatically. All built-in themes include it, which is why macros like `[require]`, `[img]`, and `[code]` are available in themed documents.
227
+ `common.ymd` ships with nattoppet in the project root. Since bare mixin paths resolve relative to the compiler root, `[mixin] common` finds it automatically. All built-in themes include it, which is why macros like `[require]`, `[img]`, and `[code]` are available in themed documents.
227
228
 
228
229
  **Trap**: If you write a bare `.ymd` without a theme and want `[require]`, you must add `[mixin] common.ymd` yourself. `[require]` is not a compiler built-in; it is a function macro defined in `common.ymd`.
229
230
 
@@ -633,7 +634,7 @@ The delimiter passed to `capture_until` is consumed from `remaining` but is **no
633
634
  | `definition X not found` | You invoked `[X]` but never defined `[X]:` or `[X]=`. | Define the macro, or check for typos. |
634
635
  | `definition X not found` inside a self-referential ref | Reference macros cannot reference themselves. | Use a function macro if you need recursion, or restructure. |
635
636
  | Multiple `[#slot]` error | A mixin contains more than one slot. | Remove extra slots, or split into multiple mixins. |
636
- | `mixin not found: X` | The mixin path could not be resolved. | Check the path; remember all mixin paths resolve relative to the compiler root, not the input file. |
637
+ | `mixin not found: X` | The mixin path could not be resolved. | Use a bare name for a built-in mixin, or begin a project-local path with `./` or `../`. |
637
638
  | Math does not render, or renders inline when it should be display | Missing `>>...<<` block delimiters around multi-line `[$$]`. | Use `[$$]>>...<<`. |
638
639
  | CJK text has unwanted spaces | Hard line breaks between CJK characters are preserved as spaces by HTML. | Wrap the text in `[cn]>>...<<`. |
639
640
  | Paragraphs wrap raw HTML | Indented HTML is treated as prose. | Remove the leading two spaces from HTML lines. |
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import { createRequire as createNattoppetRequire } from 'node:module'; const require = createNattoppetRequire(import.meta.url);
3
3
 
4
4
  // nattoppet-dev.ts
5
5
  import * as fs from "node:fs";
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import { createRequire as createNattoppetRequire } from 'node:module'; const require = createNattoppetRequire(import.meta.url);
3
3
 
4
4
  // nattoppet-init.ts
5
5
  import * as fs from "node:fs";
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import { createRequire as createNattoppetRequire } from 'node:module'; const require = createNattoppetRequire(import.meta.url);
3
3
 
4
4
  // nattoppet-native.ts
5
5
  import * as fs from "node:fs";