@reteps/tree-sitter-htmlmustache 0.0.31 → 0.0.35

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
@@ -18,9 +18,9 @@
18
18
 
19
19
  ## Features
20
20
 
21
- - **CLI Linter** — Check templates for errors from the command line
22
- - **Syntax Highlighting** — Full semantic highlighting for HTML and Mustache syntax
23
- - **Document Formatting** — Auto-format with EditorConfig support
21
+ - **Syntax Highlighting** — Full semantic highlighting for HTML and Mustache, plus embedded JS/TS in `<script>` and CSS in `<style>`
22
+ - **Document Formatting** — Auto-format with EditorConfig and config file support
23
+ - **CLI Linter & Formatter** — Check and format templates from the command line
24
24
  - **Document Symbols** — Outline view and breadcrumb navigation
25
25
  - **Folding** — Collapse HTML elements and Mustache sections
26
26
  - **Hover Information** — Tag and attribute documentation
@@ -36,12 +36,53 @@
36
36
  | `{{! comment }}` | Comments |
37
37
  | `{{> partial}}` | Partials |
38
38
 
39
+ ## VS Code Extension
40
+
41
+ Install from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=reteps.htmlmustache-lsp) or search for "HTML Mustache" in the Extensions view.
42
+
43
+ What you get out of the box:
44
+
45
+ - Syntax highlighting (including embedded JS/TS and CSS)
46
+ - Document formatting (format on save, format selection)
47
+ - Error diagnostics (parse errors, mismatched tags)
48
+ - Document outline and breadcrumbs
49
+ - Hover information for HTML tags and attributes
50
+ - Code folding for HTML elements and Mustache sections
51
+
52
+ ### Using with `.html` Files
53
+
54
+ By default, the extension activates for `.mustache`, `.hbs`, and `.handlebars` files. To use it with `.html` files, add this to your VS Code settings:
55
+
56
+ ```json
57
+ {
58
+ "files.associations": {
59
+ "*.html": "htmlmustache"
60
+ }
61
+ }
62
+ ```
63
+
64
+ You can also change the language mode for a single file by clicking the language indicator in the status bar and selecting "HTML Mustache".
65
+
39
66
  ## CLI
40
67
 
41
- Check templates for errors before committing:
68
+ Install globally or run via `npx`:
69
+
70
+ ```
71
+ npm install -g @reteps/tree-sitter-htmlmustache
72
+ ```
73
+
74
+ ### `htmlmustache check`
75
+
76
+ Check templates for parse errors:
77
+
78
+ ```
79
+ htmlmustache check '**/*.mustache' '**/*.hbs'
80
+ ```
81
+
82
+ If `include` is configured in `.htmlmustache.jsonc`, patterns are optional:
42
83
 
43
84
  ```
44
- npx @reteps/tree-sitter-htmlmustache check '**/*.mustache' '**/*.hbs'
85
+ htmlmustache check
45
86
  ```
46
87
 
47
88
  ```
@@ -55,51 +96,84 @@ file.mustache:3:3 error: Mismatched mustache section: {{/wrong}}
55
96
  1 error in 1 file (5 files checked)
56
97
  ```
57
98
 
58
- Or install globally:
99
+ Detects parse errors, mismatched Mustache sections, mismatched HTML end tags, and missing tokens.
100
+
101
+ ### `htmlmustache format`
102
+
103
+ Format templates:
59
104
 
60
105
  ```
61
- npm install -g @reteps/tree-sitter-htmlmustache
62
- htmlmustache check '**/*.mustache'
106
+ htmlmustache format --write '**/*.mustache'
63
107
  ```
64
108
 
65
- Detects parse errors, mismatched Mustache sections, mismatched HTML end tags, and missing tokens.
109
+ If `include` is configured in `.htmlmustache.jsonc`, patterns are optional:
66
110
 
67
- ## Installation
111
+ ```
112
+ htmlmustache format --write
113
+ ```
68
114
 
69
- ### VS Code Extension
115
+ Check formatting in CI (exits 1 if any files would change):
70
116
 
71
- Install from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=reteps.htmlmustache-lsp) or search for "HTML Mustache" in the Extensions view.
117
+ ```
118
+ htmlmustache format --check 'templates/**/*.hbs'
119
+ ```
72
120
 
73
- Alternatively, download `htmlmustache-lsp.vsix` from the [latest release](https://github.com/reteps/tree-sitter-htmlmustache/releases) and install via:
121
+ Read from stdin:
74
122
 
75
123
  ```
76
- code --install-extension htmlmustache-lsp.vsix
124
+ echo '<div><p>hi</p></div>' | htmlmustache format --stdin
77
125
  ```
78
126
 
79
- ### WASM
127
+ **Options:**
80
128
 
81
- Download `tree-sitter-htmlmustache.wasm` from the [latest release](https://github.com/reteps/tree-sitter-htmlmustache/releases).
129
+ | Flag | Description |
130
+ | ------------------- | ------------------------------------------------ |
131
+ | `--write` | Modify files in-place (default: print to stdout) |
132
+ | `--check` | Exit 1 if any files would change (for CI) |
133
+ | `--stdin` | Read from stdin, write to stdout |
134
+ | `--indent-size N` | Spaces per indent level (default: 2) |
135
+ | `--print-width N` | Max line width (default: 80) |
136
+ | `--mustache-spaces` | Add spaces inside mustache delimiters |
82
137
 
83
- ## Using with `.html` Files
138
+ ## Configuration
84
139
 
85
- By default, the extension activates for `.mustache`, `.hbs`, and `.handlebars` files. To use it with `.html` files, add this to your VS Code settings:
140
+ ### `.htmlmustache.jsonc`
86
141
 
87
- ```json
142
+ Create a `.htmlmustache.jsonc` file in your project root to configure formatting options. Both the VS Code extension and CLI will pick it up automatically (the file is found by walking up from the formatted file).
143
+
144
+ ```jsonc
88
145
  {
89
- "files.associations": {
90
- "*.html": "htmlmustache"
91
- }
146
+ // File patterns for CLI commands (used when no patterns are passed as arguments)
147
+ "include": ["**/*.mustache", "**/*.hbs"],
148
+
149
+ // Patterns to always exclude (node_modules and .git are excluded by default)
150
+ "exclude": ["**/vendor/**"],
151
+
152
+ // Max line width before wrapping (default: 80)
153
+ "printWidth": 100,
154
+
155
+ // Spaces per indent level (default: 2)
156
+ "indentSize": 4,
157
+
158
+ // Add spaces inside mustache delimiters: {{ foo }} vs {{foo}} (default: false)
159
+ "mustacheSpaces": true,
160
+
161
+ // Treat custom tags as raw code blocks (like <script>/<style>)
162
+ "customCodeTags": [
163
+ {
164
+ "name": "x-code",
165
+ "languageDefault": "javascript",
166
+ },
167
+ ],
92
168
  }
93
169
  ```
94
170
 
95
- You can also change the language mode for a single file by clicking the language indicator in the status bar and selecting "HTML Mustache".
171
+ ### EditorConfig
96
172
 
97
- ## Acknowledgments
173
+ Both the CLI and VS Code extension respect your `.editorconfig` file for indentation settings (`indent_style`, `indent_size`). EditorConfig values override `.htmlmustache.jsonc` for indentation, and CLI flags override everything.
98
174
 
99
- This project is based on [tree-sitter-html](https://github.com/tree-sitter/tree-sitter-html) by Max Brunsfeld and Amaan Qureshi.
175
+ **Priority order:** defaults < `.htmlmustache.jsonc` < `.editorconfig` (indent only) < CLI flags
100
176
 
101
- ## References
177
+ ## Acknowledgments
102
178
 
103
- - [The HTML5 Spec](https://www.w3.org/TR/html5/syntax.html)
104
- - [Mustache Manual](https://mustache.github.io/mustache.5.html)
105
- - [Handlebars Language Guide](https://handlebarsjs.com/guide/)
179
+ This project is based on [tree-sitter-html](https://github.com/tree-sitter/tree-sitter-html) by Max Brunsfeld and Amaan Qureshi.