|
32 | 32 | <script> |
33 | 33 | window.she = window.she || {}; |
34 | 34 | window.she.config = { |
| 35 | + // Define languages to support |
35 | 36 | languages: ['html', 'css', 'js', 'jsx', 'md'], |
36 | | - // Optional: language specific token type overwrites |
| 37 | + // Language specific token type overwrites |
37 | 38 | languageTokens: { |
38 | 39 | css: ['important'], |
39 | 40 | md: ['title', 'list'], |
40 | 41 | }, |
41 | | - // Optional: extend/customize tokenizer |
42 | | - // tokenizer: { |
43 | | - // async setup() {}, |
44 | | - // tokenize: () => [], |
45 | | - // } |
| 42 | + // Customize setup/tokenize method |
| 43 | + // async setup() {}, |
| 44 | + // tokenize: () => [], |
46 | 45 | } |
47 | 46 | </script> |
48 | 47 | </head> |
|
92 | 91 | </syntax-highlight> |
93 | 92 |
|
94 | 93 | <script type="module"> |
95 | | - // /** |
96 | | - // * Option 1. autoload - default |
97 | | - // */ |
98 | | - // import '/src/index.js' |
99 | | - import SyntaxHighlightElement from '/src/index.js' |
100 | | - // import SyntaxHighlightElement from '/src/index.js?define=false' |
101 | | - // SyntaxHighlightElement.config.languages = ['html', 'css', 'js', 'jsx', 'md']; |
102 | | - // window.SyntaxHighlightElement = await SyntaxHighlightElement.define(); |
103 | | - |
104 | 94 | /** |
105 | | - * Option 2. Opt out of prism autoload by manually importing prism core |
| 95 | + * Option 1. autoload - default |
106 | 96 | */ |
107 | | - // import 'https://cdn.jsdelivr.net/npm/prismjs@1.30.0/components/prism-core.min.js' |
108 | | - // import SyntaxHighlightElement from '/src/index.js?define=false' |
| 97 | + import '/src/index.js' |
109 | 98 |
|
110 | 99 | /** |
111 | | - * Option 2.a. Load lang deps manually (without dependency resolution) |
| 100 | + * Option 2.a. Opt out of prism autoload by manually importing prism core |
| 101 | + */ |
| 102 | + // import 'prismjs/components/prism-core' |
| 103 | + /** |
| 104 | + * Option 2.b. Load lang deps manually (without dependency resolution) |
112 | 105 | */ |
113 | | - // // - CDN |
114 | | - // import 'https://cdn.jsdelivr.net/npm/prismjs@1.30.0/components/prism-markup.min.js' |
115 | | - // import 'https://cdn.jsdelivr.net/npm/prismjs@1.30.0/components/prism-css.min.js' |
116 | | - // import 'https://cdn.jsdelivr.net/npm/prismjs@1.30.0/components/prism-clike.min.js' |
117 | | - // import 'https://cdn.jsdelivr.net/npm/prismjs@1.30.0/components/prism-javascript.min.js' |
118 | | - // import 'https://cdn.jsdelivr.net/npm/prismjs@1.30.0/components/prism-jsx.min.js' |
119 | | - // import 'https://cdn.jsdelivr.net/npm/prismjs@1.30.0/components/prism-markdown.min.js' |
120 | | - // // - npm |
121 | 106 | // import 'prismjs/components/prism-markup' |
122 | 107 | // import 'prismjs/components/prism-css' |
123 | 108 | // import 'prismjs/components/prism-clike' |
124 | 109 | // import 'prismjs/components/prism-javascript' |
125 | 110 | // import 'prismjs/components/prism-jsx' |
126 | 111 | // import 'prismjs/components/prism-markdown' |
127 | | - |
128 | | - /** |
129 | | - * Option 2.b. resolve language dependencies and load from URL/CDN |
130 | | - */ |
131 | | - // - CDN |
132 | | - // import { loadPrismLanguage } from '/src/tokenizer/prism.js' |
133 | | - // await loadPrismLanguage({ |
134 | | - // baseUrl: 'https://unpkg.com/prismjs@1.30.0', |
135 | | - // language: window.she.config.languages |
136 | | - // }); |
137 | | - // // - npm |
138 | | - // import { resolveLanguageDependencies } from '/src/tokenizer/prism.js' |
139 | | - // const langDeps = resolveLanguageDependencies(window.she.config.languages); |
140 | | - // for await (const lang of langDeps) { |
141 | | - // const importPath = `prismjs/components/prism-${lang}` |
142 | | - // await import(importPath); |
143 | | - // console.log({importPath}) |
144 | | - // } |
145 | | - // // - Manually define SyntaxHighlightElement with ?define=false once all dependecies are loaded |
146 | | - // window.SyntaxHighlightElement = await SyntaxHighlightElement.define(); |
| 112 | + // ... |
147 | 113 | </script> |
148 | 114 | <script> |
149 | 115 | document.addEventListener('DOMContentLoaded', () => { |
|
0 commit comments