Skip to content
This repository was archived by the owner on Sep 26, 2022. It is now read-only.

Commit bb0c0fa

Browse files
docs: inject MaterialApp into prism code
Signed-off-by: Florian-Schoenherr <[email protected]>
1 parent e8a04a2 commit bb0c0fa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/docs/scripts/examples.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ export default {
55
name: 'examples',
66
transform(code, id) {
77
if (id.includes('examples')) {
8-
const highlighted = Prism.highlight(code, Prism.languages.svelte, 'svelte');
8+
// some files still have CRLF line-endings, that's why the last 3 replaces aren't combined
9+
// when that's solved, do .replace('</script>\n', '</script>\n\n<MaterialApp>') instead
10+
const codeWithMaterialAppAdded = `${code
11+
.replace(' } from \'svelte-materialify/src\'', ', MaterialApp } from \'svelte-materialify/src\'')
12+
.replace('</script>', '</script>\n\n<MaterialApp>')
13+
.replace('<MaterialApp>\n', '<MaterialApp>')
14+
.replace('<MaterialApp>\r\n', '<MaterialApp>')}</MaterialApp>`;
15+
const highlighted = Prism.highlight(codeWithMaterialAppAdded, Prism.languages.svelte, 'svelte');
916
const output = `<script context="module">export const source = ${JSON.stringify(
1017
highlighted,
1118
)}</script>`;

0 commit comments

Comments
 (0)