Add VS Code TextMate grammar for #@ directives in manual/*.md#3047
Merged
Conversation
A minimal grammar-only VS Code extension that injects highlighting for the #@ preprocessor directives into the built-in Markdown highlighting (tools/vscode/rurema-markdown, install by symlinking into ~/.vscode/extensions). Covers the same directive set as bitclust's Preprocessor: #@SInCE, #@until, #@if, #@else, #@EnD, #@include, #@SampleCode, #@todo and #@# comments, at column 0 only, matching the preprocessor's behavior. Any other column-0 #@ line is shown as invalid, because it would be a parse error at build time — this doubles as typo detection while editing. Validated against the whole manual/ tree: all 10,062 column-0 #@ lines classify into the intended patterns (0 fall out as invalid or unmatched), and synthetic typos/malformed directives are flagged invalid. Every regex compiles under Onigmo, which approximates the Oniguruma engine TextMate uses. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tools/ holds editor tooling (the VS Code grammar), which does not affect the manual build, in the same way docs/ and the frozen refm/ do not. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
manual/**/*.mdを VS Code で編集するときに#@プリプロセッサ指令をハイライトする TextMate grammar を追加します(MARKUP_SPEC §15 の
「エディタ支援:
#@指令用の VS Code TextMate grammar 作成」の実装)。tools/vscode/rurema-markdown/に文法のみの最小構成の拡張として配置:package.json— Markdown への injection grammar として contribute(既存の Markdown ハイライトはそのまま、
#@行にだけ色を足す)syntaxes/rurema-directives.tmLanguage.json— 文法本体README.md— インストール手順(~/.vscode/extensions/へ symlink)と対応範囲設計のポイント(bitclust Preprocessor と同じ解釈)
#@行だけを指令として扱う(インデントされた#@は本文。Preprocessor の
\Aアンカーと同じ)#@since/#@until(バージョン値を強調)・#@if(version・比較/論理演算子・文字列を強調)・
#@else/#@end(後続テキスト不可)・#@include(path)・#@samplecode [ラベル]・#@todo(大文字小文字不問)・#@#コメント#@は invalid(エラー色)表示 — ビルドでもparse error になる行なので、編集中のタイポ検出を兼ねる
リスト)の
#@も処理するため、injection はそれらの領域にも適用される検証
#@全 10,062 行をパターン順で分類:#@#4,028 /#@else・#@end2,970 /#@since・#@until2,099 /#@todo737 /#@include124 /#@if103 /#@samplecode1、invalid・未分類は 0 行(= 実在する正しい指令を誤ってエラー表示しない)
#@sinse・バージョン欠落・#@else foo等)が invalid に落ち、非対象 4 種(インデント付き・
\#@エスケープ・行中の#@)はマッチしないことを確認(symlink → ウィンドウ再読み込み → manual/ の適当な .md を開く)
CI
tools/**はマニュアルのビルドに影響しないため、docs/**・refm/**と同様にCI の
paths-ignoreと misspell の対象から除外しました(2コミット目)。除外後も misspell の対象が正しく残ることをローカルで確認済み
(
git ls-files1,270 ファイル、tools/docs/refm は 0)。なお本 PR 自体は
.github/workflows/ci.ymlを変更しているため CI が一度走ります(
paths-ignoreは変更ファイル全部が ignore に一致した場合のみスキップ)。workflow 変更の検証を兼ねるのでそのままにしています。
除外が効くのは今後の tools/ のみの変更からです。
🤖 Generated with Claude Code