prosemirror-highlight 0.15.0 → 0.15.1

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.
Files changed (2) hide show
  1. package/README.md +39 -0
  2. package/package.json +9 -9
package/README.md CHANGED
@@ -157,6 +157,44 @@ export const refractorPlugin = createHighlightPlugin({ parser })
157
157
 
158
158
  </details>
159
159
 
160
+ ### With [Lezer]
161
+
162
+ <details>
163
+ <summary>Using Lezer parsers with classHighlighter</summary>
164
+
165
+ ```ts
166
+ import type { Tree } from '@lezer/common'
167
+ import { parser as cssParser } from '@lezer/css'
168
+ import { classHighlighter } from '@lezer/highlight'
169
+ import { parser as javascriptParser } from '@lezer/javascript'
170
+ import { createHighlightPlugin } from 'prosemirror-highlight'
171
+ import { createParser, type ParserOptions } from 'prosemirror-highlight/lezer'
172
+
173
+ function parse({ content, language }: ParserOptions): Tree | undefined {
174
+ const lang = language?.toLowerCase() || ''
175
+ switch (lang) {
176
+ case 'js':
177
+ case 'javascript':
178
+ case 'ts':
179
+ case 'typescript':
180
+ case 'jsx':
181
+ case 'tsx':
182
+ return javascriptParser.parse(content)
183
+ case 'css':
184
+ case 'scss':
185
+ case 'sass':
186
+ return cssParser.parse(content)
187
+ default:
188
+ return undefined
189
+ }
190
+ }
191
+
192
+ const parser = createParser({ highlighter: classHighlighter, parse })
193
+ export const lezerPlugin = createHighlightPlugin({ parser })
194
+ ```
195
+
196
+ </details>
197
+
160
198
  ### With [Sugar high]
161
199
 
162
200
  <details>
@@ -223,5 +261,6 @@ MIT
223
261
  [Highlight.js]: https://github.com/highlightjs/highlight.js
224
262
  [Shiki]: https://github.com/shikijs/shiki
225
263
  [refractor]: https://github.com/wooorm/refractor
264
+ [Lezer]: https://lezer.codemirror.net
226
265
  [Prism]: https://github.com/PrismJS/prism
227
266
  [Sugar high]: https://github.com/huozhi/sugar-high
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prosemirror-highlight",
3
3
  "type": "module",
4
- "version": "0.15.0",
4
+ "version": "0.15.1",
5
5
  "description": "A ProseMirror plugin to highlight code blocks",
6
6
  "author": "ocavue <ocavue@gmail.com>",
7
7
  "license": "MIT",
@@ -58,7 +58,7 @@
58
58
  "peerDependencies": {
59
59
  "@lezer/common": "^1.0.0",
60
60
  "@lezer/highlight": "^1.0.0",
61
- "@shikijs/types": "^1.29.2 || ^2.0.0 || ^3.0.0",
61
+ "@shikijs/types": "^1.29.2 || ^2.0.0 || ^3.0.0 || ^4.0.0",
62
62
  "@types/hast": "^3.0.0",
63
63
  "highlight.js": "^11.9.0",
64
64
  "lowlight": "^3.1.0",
@@ -67,7 +67,7 @@
67
67
  "prosemirror-transform": "^1.8.0",
68
68
  "prosemirror-view": "^1.32.4",
69
69
  "refractor": "^5.0.0",
70
- "sugar-high": "^0.6.1 || ^0.7.0 || ^0.8.0 || ^0.9.0"
70
+ "sugar-high": "^0.6.1 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^1.0.0"
71
71
  },
72
72
  "peerDependenciesMeta": {
73
73
  "@lezer/common": {
@@ -109,18 +109,18 @@
109
109
  },
110
110
  "devDependencies": {
111
111
  "@lezer/common": "^1.5.1",
112
- "@lezer/css": "^1.3.0",
112
+ "@lezer/css": "^1.3.1",
113
113
  "@lezer/highlight": "^1.2.3",
114
114
  "@lezer/javascript": "^1.5.4",
115
- "@ocavue/eslint-config": "^3.11.2",
115
+ "@ocavue/eslint-config": "^4.2.0",
116
116
  "@ocavue/tsconfig": "^0.6.3",
117
- "@shikijs/types": "^3.22.0",
117
+ "@shikijs/types": "^4.0.0",
118
118
  "@types/hast": "^3.0.4",
119
119
  "@types/node": "^24.0.0",
120
120
  "diffable-html-snapshot": "^0.2.0",
121
- "eslint": "^9.39.2",
121
+ "eslint": "^10.0.2",
122
122
  "highlight.js": "^11.11.1",
123
- "jsdom": "^28.0.0",
123
+ "jsdom": "^28.1.0",
124
124
  "lowlight": "^3.3.0",
125
125
  "pkg-pr-new": "^0.0.63",
126
126
  "prettier": "^3.8.1",
@@ -131,7 +131,7 @@
131
131
  "prosemirror-transform": "^1.11.0",
132
132
  "prosemirror-view": "^1.41.6",
133
133
  "refractor": "^5.0.0",
134
- "shiki": "^3.22.0",
134
+ "shiki": "^4.0.0",
135
135
  "sugar-high": "^0.9.5",
136
136
  "tsdown": "^0.20.3",
137
137
  "typescript": "^5.9.3",