Skip to content

Commit bff5e0b

Browse files
committed
docs: add configuration section
1 parent 16a2519 commit bff5e0b

File tree

2 files changed

+47
-19
lines changed

2 files changed

+47
-19
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ Or via CDN
6363
* `language` The code language. The default is `plaintext`. Currently suported languages `html|css|js`.
6464
* `content-selector` A CSS selector to specify the content element. The default is the element itself.
6565

66+
## Configuration
67+
```js
68+
/**
69+
* @typedef Config
70+
* @type {object}
71+
* @property {string[]} [languages=['markup', 'css', 'javascript']] - Language grammars to highlight.
72+
* @property {{ [key: string]: string[] }} languageTokens - Language specific token types.
73+
*/
74+
window.she = window.she || {};
75+
/** @type {Config} */
76+
window.she.config = {};
77+
```
78+
6679
## Browser Support
6780

6881
<picture>
@@ -75,7 +88,7 @@ Or via CDN
7588
## Credits
7689

7790
* [Bramus Van Damme][bramus_github] and his [blog post][bramus_blog_post] where I first read about using the [CSS Custom Highlight API][MDN_CSS_Custom_Highlight_API] for syntax highlighting.
78-
* [Prism][prism_github]'s tokenizer
91+
* [Prism][prism_github]'s tokenizer.
7992

8093
## License
8194

docs/index.html

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ <h1 class="tagline">A custom element that uses the CSS Custom Highlight API for
9292
</section>
9393

9494
<section data-section="content">
95+
<h1>Installation &amp; Usage</h1>
9596
<article>
96-
<h1>Installation & Usage</h1>
97-
9897
<h2>Install</h2>
9998
<p>Install via npm</p>
10099
<div class="copy-code">
101100
<syntax-highlight id="copy-install-npm">npm install syntax-highlight-element</syntax-highlight>
102101
<clipboard-copy for="copy-install-npm" class="button">Copy</clipboard-copy>
103102
</div>
104-
103+
</article>
104+
<article>
105105
<h2>Usage</h2>
106106
<h3>JavaScript</h3>
107107
<p>Import as ES module</p>
@@ -111,8 +111,7 @@ <h3>JavaScript</h3>
111111
</div>
112112
<p>Or via CDN</p>
113113
<div class="copy-code">
114-
<syntax-highlight language="html" id="copy-usage-cdn">&lt;link rel="stylesheet" href="https://unpkg.com/syntax-highlight-element@latest/dist/themes/prettylights.css"&gt;
115-
&lt;script type="module" src="https://unpkg.com/syntax-highlight-element@latest/dist/syntax-highlight-element.js"&gt;&lt;/script&gt;</syntax-highlight>
114+
<syntax-highlight language="html" id="copy-usage-cdn">&lt;script type="module" src="https://unpkg.com/syntax-highlight-element@latest/dist/syntax-highlight-element.js"&gt;&lt;/script&gt;</syntax-highlight>
116115
<clipboard-copy for="copy-usage-cdn" class="button">Copy</clipboard-copy>
117116
</div>
118117
<h3>HTML</h3>
@@ -129,23 +128,39 @@ <h3>CSS</h3>
129128
<syntax-highlight language="html" id="copy-usage-cdn">&lt;link rel="stylesheet" href="https://unpkg.com/syntax-highlight-element@latest/dist/themes/prettylights.css"&gt;</syntax-highlight>
130129
<clipboard-copy for="copy-usage-cdn" class="button">Copy</clipboard-copy>
131130
</div>
132-
133-
<h2>Attributes</h2>
134-
<ul>
135-
<li><code>language</code> The syntax language. The default is <code>plaintext</code>. Currently suported languages <code>html|css|js</code>.
136-
<li><code>content-selector</code> A CSS selector to specify the content element. The default is the element itself.
137-
</ul>
138131
</article>
139132
</section>
140133

141134
<section data-section="content">
142-
<article>
143-
<h1>Credits</h1>
144-
<ul>
145-
<li><a href="https://github.com/bramus" target="_blank" rel="noreferrer">Bramus Van Damme</a> and his <a href="https://www.bram.us/2024/02/18/custom-highlight-api-for-syntax-highlighting" target="_blank">blog post</a> where I first read about using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API" target="_blank">CSS Custom Highlight API</a> for syntax highlighting.
146-
<li><a href="https://github.com/PrismJS/prism" target="_blank" rel="noreferrer">Prism</a>'s tokenizer
147-
</ul>
148-
</article>
135+
<h1>Attributes</h1>
136+
<ul>
137+
<li><code>language</code> The syntax language. The default is <code>plaintext</code>. Currently suported languages <code>html|css|js</code>.
138+
<li><code>content-selector</code> A CSS selector to specify the content element. The default is the element itself.
139+
</ul>
140+
</section>
141+
142+
<section data-section="content">
143+
<h1>Configuration</h1>
144+
<div class="copy-code">
145+
<syntax-highlight language="js" id="copy-config">/**
146+
* @typedef Config
147+
* @type {object}
148+
* @property {string[]} [languages=['markup', 'css', 'javascript']] - Language grammars to highlight.
149+
* @property {{ [key: string]: string[] }} languageTokens - Language specific token types.
150+
*/
151+
window.she = window.she || {};
152+
/** @type {Config} */
153+
window.she.config = {};</syntax-highlight>
154+
<clipboard-copy for="copy-config" class="button">Copy</clipboard-copy>
155+
</div>
156+
</section>
157+
158+
<section data-section="content">
159+
<h1>Credits</h1>
160+
<ul>
161+
<li><a href="https://github.com/bramus" target="_blank" rel="noreferrer">Bramus Van Damme</a> and his <a href="https://www.bram.us/2024/02/18/custom-highlight-api-for-syntax-highlighting" target="_blank">blog post</a> where I first read about using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API" target="_blank">CSS Custom Highlight API</a> for syntax highlighting.
162+
<li><a href="https://github.com/PrismJS/prism" target="_blank" rel="noreferrer">Prism</a>'s tokenizer.
163+
</ul>
149164
</section>
150165
</main>
151166

0 commit comments

Comments
 (0)