nunjucks-parser-maintenance
Perform maintenance tasks for @markuplint/nunjucks-parser: modify ignoreTags configuration,
add new Nunjucks syntax patterns, and update tests.
Input
$ARGUMENTS specifies the task. Supported tasks:
| Task | Description |
|---|---|
modify-ignoretag | Modify or add an ignoreTags pattern |
fix-parsing | Fix a parsing issue with Nunjucks HTML |
add-test | Add a new test case |
If omitted, defaults to modify-ignoretag.
Reference
Before executing any task, read docs/maintenance.md (or docs/maintenance.ja.md)
for the full guide. The recipes there are the source of truth for procedures.
Also read:
- •
ARCHITECTURE.md-- Package overview, ignoreTags table, and integration points - •
src/parser.ts-- NunjucksParser class (source of truth for ignore patterns)
Task: modify-ignoretag
Modify or add an ignoreTags pattern. Follow recipe #1 in docs/maintenance.md.
Step 1: Understand the current patterns
- •Read
src/parser.tsand review theignoreTagsarray in the constructor - •Each entry has
type(node name),start(opening delimiter), andend(closing delimiter)
Step 2: Make the change
- •Add or modify entries in the
ignoreTagsarray - •If the new pattern overlaps with existing patterns, place the more specific pattern first
- •Use a regex string for
startif a simple string match is insufficient
Step 3: Verify
- •Build:
yarn build --scope @markuplint/nunjucks-parser - •Add test cases to
src/index.spec.ts - •Test:
yarn test --scope @markuplint/nunjucks-parser
Task: fix-parsing
Fix a parsing issue with Nunjucks-containing HTML. Follow recipe #2 in docs/maintenance.md.
Step 1: Reproduce
- •Add a failing test case to
src/index.spec.tsusingnodeListToDebugMaps - •Run:
yarn test --scope @markuplint/nunjucks-parser
Step 2: Diagnose
- •Check if the issue is in ignoreTags patterns (
src/parser.ts) or in the upstreamHtmlParser - •If the issue is upstream, fix it in
@markuplint/html-parserinstead
Step 3: Verify
- •Build:
yarn build --scope @markuplint/nunjucks-parser - •Test:
yarn test --scope @markuplint/nunjucks-parser
Task: add-test
Add a new test case. Follow recipe #3 in docs/maintenance.md.
Step 1: Write the test
- •Read
src/index.spec.tsfor existing patterns - •Use
nodeListToDebugMapsfor snapshot-style assertions - •Use
parser.parse(source).nodeListto get the node list
Step 2: Verify
- •Test:
yarn test --scope @markuplint/nunjucks-parser
Rules
- •Never override HtmlParser methods in
NunjucksParser-- this parser is ignoreTags-only. - •Order ignoreTags from most specific to least specific when patterns share a common prefix.
- •Add JSDoc comments to all new public methods and properties.
- •Test all three expression types (block, output, comment) when modifying patterns.