Skip to content

notation: warn when a directive is not in a comment the language reads - #5

Merged
ewels merged 1 commit into
mainfrom
feat/warn-directive-outside-comment
Oct 5, 2026
Merged

ewels merged 1 commit into
mainfrom
feat/warn-directive-outside-comment

Conversation

@ewels

@ewels ewels commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Closes #1

A directive written in a comment syntax that the block's language does not read, such as <!-- [!callout …] --> in an mdx block or // [!code focus] in a Python block, stayed in the code as text with no build warning. parseLine() in notation.ts, the one place every directive goes through, now warns when a line has no comment that holds a directive but has a known, unescaped directive outside a string. The message names the syntaxes to use, for example: src/content/docs/example.md, mdx code block, line 1: [!callout /import/]is not in a comment that this block reads. Use{/* */}. It shows as text.

Which blocks warn: only languages that have a comment syntax (built-in or from notation.comments). A language with no syntax, or one set to [] (the docs site does this for md, markdown and mdx), reads no directives and never warns. Escaped directives ([\!code …]), directives in a string, and unknown [!word] text such as Markdown alerts or arr[!flag] stay silent. No new opt-out was added; the decision is in .agents/DECISIONS.md.

pnpm lint, pnpm test, pnpm lint:docs and pnpm docs:build pass, and the docs build logs no warnings.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ewels
ewels merged commit c62d647 into main Oct 5, 2026
3 checks passed
@ewels
ewels deleted the feat/warn-directive-outside-comment branch October 5, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn when directive text is not inside a comment the block's language reads

1 participant