@reteps/tree-sitter-htmlmustache 0.0.30 → 0.0.34

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,47 @@
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`:
42
69
 
43
70
  ```
44
- npx @reteps/tree-sitter-htmlmustache check '**/*.mustache' '**/*.hbs'
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'
45
80
  ```
46
81
 
47
82
  ```
@@ -55,51 +90,72 @@ file.mustache:3:3 error: Mismatched mustache section: {{/wrong}}
55
90
  1 error in 1 file (5 files checked)
56
91
  ```
57
92
 
58
- Or install globally:
93
+ Detects parse errors, mismatched Mustache sections, mismatched HTML end tags, and missing tokens.
59
94
 
60
- ```
61
- npm install -g @reteps/tree-sitter-htmlmustache
62
- htmlmustache check '**/*.mustache'
63
- ```
95
+ ### `htmlmustache format`
64
96
 
65
- Detects parse errors, mismatched Mustache sections, mismatched HTML end tags, and missing tokens.
97
+ Format templates:
66
98
 
67
- ## Installation
99
+ ```
100
+ htmlmustache format --write '**/*.mustache'
101
+ ```
68
102
 
69
- ### VS Code Extension
103
+ Check formatting in CI (exits 1 if any files would change):
70
104
 
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.
105
+ ```
106
+ htmlmustache format --check 'templates/**/*.hbs'
107
+ ```
72
108
 
73
- Alternatively, download `htmlmustache-lsp.vsix` from the [latest release](https://github.com/reteps/tree-sitter-htmlmustache/releases) and install via:
109
+ Read from stdin:
74
110
 
75
111
  ```
76
- code --install-extension htmlmustache-lsp.vsix
112
+ echo '<div><p>hi</p></div>' | htmlmustache format --stdin
77
113
  ```
78
114
 
79
- ### WASM
115
+ **Options:**
80
116
 
81
- Download `tree-sitter-htmlmustache.wasm` from the [latest release](https://github.com/reteps/tree-sitter-htmlmustache/releases).
117
+ | Flag | Description |
118
+ | -------------------- | ---------------------------------------------- |
119
+ | `--write` | Modify files in-place (default: print to stdout) |
120
+ | `--check` | Exit 1 if any files would change (for CI) |
121
+ | `--stdin` | Read from stdin, write to stdout |
122
+ | `--indent-size N` | Spaces per indent level (default: 2) |
123
+ | `--print-width N` | Max line width (default: 80) |
124
+ | `--mustache-spaces` | Add spaces inside mustache delimiters |
82
125
 
83
- ## Using with `.html` Files
126
+ ## Configuration
84
127
 
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:
128
+ ### `.htmlmustache.jsonc`
86
129
 
87
- ```json
130
+ 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).
131
+
132
+ ```jsonc
88
133
  {
89
- "files.associations": {
90
- "*.html": "htmlmustache"
91
- }
134
+ // Max line width before wrapping (default: 80)
135
+ "printWidth": 100,
136
+
137
+ // Spaces per indent level (default: 2)
138
+ "indentSize": 4,
139
+
140
+ // Add spaces inside mustache delimiters: {{ foo }} vs {{foo}} (default: false)
141
+ "mustacheSpaces": true,
142
+
143
+ // Treat custom tags as raw code blocks (like <script>/<style>)
144
+ "customCodeTags": [
145
+ {
146
+ "name": "x-code",
147
+ "languageDefault": "javascript"
148
+ }
149
+ ]
92
150
  }
93
151
  ```
94
152
 
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".
153
+ ### EditorConfig
96
154
 
97
- ## Acknowledgments
155
+ 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
156
 
99
- This project is based on [tree-sitter-html](https://github.com/tree-sitter/tree-sitter-html) by Max Brunsfeld and Amaan Qureshi.
157
+ **Priority order:** defaults < `.htmlmustache.jsonc` < `.editorconfig` (indent only) < CLI flags
100
158
 
101
- ## References
159
+ ## Acknowledgments
102
160
 
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/)
161
+ This project is based on [tree-sitter-html](https://github.com/tree-sitter/tree-sitter-html) by Max Brunsfeld and Amaan Qureshi.