Skip to content

Commit 6e82b47

Browse files
fix markdown
1 parent a335e6a commit 6e82b47

File tree

1 file changed

+56
-62
lines changed

1 file changed

+56
-62
lines changed

apps/docs/src/routes/playground/initial-content.md

Lines changed: 56 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# A demo of \`sveltedown\`
1+
# A demo of `sveltedown`
22

3-
\`sveltedown\` is a markdown component for Svelte.
3+
`sveltedown` is a markdown component for Svelte.
44

55
👉 Changes are re-rendered as you type.
66

@@ -10,74 +10,72 @@
1010

1111
- Follows [CommonMark](https://commonmark.org)
1212
- Optionally follows [GitHub Flavored Markdown](https://github.github.com/gfm/)
13-
- Renders Svelte elements -- no \`@html\` needed
14-
- Lets you define your own snippets (to \`@render myHeading\` instead of \`'h1'\`)
13+
- Renders Svelte elements -- no `@html` needed
14+
- Lets you define your own snippets (to `@render myHeading` instead of `'h1'`)
1515
- Has a lot of plugins
1616

1717
## Contents
1818

1919
Here is an example of a plugin in action
20-
([\`remark-toc\`](https://github.com/remarkjs/remark-toc)).
20+
([`remark-toc`](https://github.com/remarkjs/remark-toc)).
2121
**This section is replaced by an actual table of contents**.
2222

2323
## Syntax highlighting
2424

2525
Here is an example of a plugin to highlight code:
26-
[\`@shikijs/rehype\`](https://shiki.matsu.io/packages/rehype).
26+
[`@shikijs/rehype`](https://shiki.matsu.io/packages/rehype).
2727

28-
Create a shared highlighter in \`load\`:
28+
Create a shared highlighter in `load`:
2929

30-
\`\`\`ts
30+
```ts
3131
// src/routes/+page.ts
3232
import { createHighlighterCore } from 'shiki/core';
3333
import { createOnigurumaEngine } from 'shiki/engine/oniguruma';
3434

3535
export const load = async () => {
36-
const highlighter = await createHighlighterCore({
37-
themes: [import('@shikijs/themes/github-light'), import('@shikijs/themes/github-dark')],
38-
langs: [
39-
import('@shikijs/langs/svelte'),
40-
import('@shikijs/langs/javascript'),
41-
import('@shikijs/langs/typescript'),
42-
import('@shikijs/langs/markdown')
43-
],
44-
engine: createOnigurumaEngine(() => import('shiki/wasm'))
45-
});
46-
47-
return {
48-
highlighter,
49-
};
50-
36+
const highlighter = await createHighlighterCore({
37+
themes: [import('@shikijs/themes/github-light'), import('@shikijs/themes/github-dark')],
38+
langs: [
39+
import('@shikijs/langs/svelte'),
40+
import('@shikijs/langs/javascript'),
41+
import('@shikijs/langs/typescript'),
42+
import('@shikijs/langs/markdown')
43+
],
44+
engine: createOnigurumaEngine(() => import('shiki/wasm'))
45+
});
46+
47+
return {
48+
highlighter
49+
};
5150
};
52-
\`\`\`
51+
```
5352

5453
...and then use it in your component:
5554

56-
\`\`\`svelte
57-
55+
```svelte
5856
<script lang="ts">
59-
// src/routes/+page.svelte
60-
import { Markdown } from 'sveltedown';
61-
import rehypeShikiFromHighlighter from '@shikijs/rehype/core';
57+
// src/routes/+page.svelte
58+
import { Markdown } from 'sveltedown';
59+
import rehypeShikiFromHighlighter from '@shikijs/rehype/core';
6260
63-
const { data } = $props();
61+
const { data } = $props();
6462
65-
let content = $state('');
63+
let content = $state('');
6664
</script>
6765
6866
<Markdown
69-
{content}
70-
rehypePlugins={[
71-
[
72-
rehypeShikiFromHighlighter,
73-
data.highlighter,
74-
{ themes: { light: 'github-light', dark: 'github-dark' } }
75-
]
76-
]}
67+
{content}
68+
rehypePlugins={[
69+
[
70+
rehypeShikiFromHighlighter,
71+
data.highlighter,
72+
{ themes: { light: 'github-light', dark: 'github-dark' } }
73+
]
74+
]}
7775
/>
78-
\`\`\`
76+
```
7977

80-
Alternatively, if you're using \`experimental.async\`, you can use \`MarkdownAsync\` instead, which doesn't require setting up your highlighter in \`load\`.
78+
Alternatively, if you're using `experimental.async`, you can use `MarkdownAsync` instead, which doesn't require setting up your highlighter in `load`.
8179
If you're doing lots of highlighting, though, it's probably better to create your highlighter in some higher-level root scope and share it via context so that it
8280
doesn't have to be recreated over and over again.
8381

@@ -86,17 +84,17 @@ Pretty neat, eh?
8684
## GitHub flavored markdown (GFM)
8785

8886
For GFM, you can _also_ use a plugin:
89-
[\`remark-gfm\`](https://github.com/remarkjs/remark-gfm).
87+
[`remark-gfm`](https://github.com/remarkjs/remark-gfm).
9088
It adds support for GitHub-specific extensions to the language:
9189
tables, strikethrough, tasklists, and literal URLs.
9290

9391
These features **do not work by default**.
9492
👆 Use the toggle above to add the plugin.
9593

96-
| Feature | Support |
97-
| ---------: | :--------------------- |
98-
| CommonMark | 100% |
99-
| GFM | 100% w/ \`remark-gfm\` |
94+
| Feature | Support |
95+
| ---------: | :------------------- |
96+
| CommonMark | 100% |
97+
| GFM | 100% w/ `remark-gfm` |
10098

10199
~~strikethrough~~
102100

@@ -108,38 +106,34 @@ https://example.com
108106
## HTML in markdown
109107

110108
⚠️ HTML in markdown is quite unsafe, but if you want to support it, you can
111-
use [\`rehype-raw\`](https://github.com/rehypejs/rehype-raw).
109+
use [`rehype-raw`](https://github.com/rehypejs/rehype-raw).
112110
You should probably combine it with
113-
[\`rehype-sanitize\`](https://github.com/rehypejs/rehype-sanitize).
111+
[`rehype-sanitize`](https://github.com/rehypejs/rehype-sanitize).
114112

115113
<blockquote>
116114
👆 Use the toggle above to add the plugin.
117115
</blockquote>
118116

119117
## Components
120118

121-
You can render custom content by mapping HTML elements to other HTML elements or by passing snippets for full custom control over rendering. HTML and SVG element tags are available as props directly on \`Markdown\`.
122-
123-
\`\`\`svelte filename=src/lib/markdown.svelte
119+
You can render custom content by mapping HTML elements to other HTML elements or by passing snippets for full custom control over rendering. HTML and SVG element tags are available as props directly on `Markdown`.
124120

121+
```svelte
125122
<script lang="ts">
126-
import { Markdown } from 'sveltedown';
127-
import MyFancyDiv from '$lib/my-fancy-div.svelte';
123+
import { Markdown } from 'sveltedown';
124+
import MyFancyDiv from '$lib/my-fancy-div.svelte';
128125
129-
let content = $state('');
126+
let content = $state('');
130127
</script>
131128
132129
<!-- use h2s instead of h1s for # headings -->
133-
134130
<Markdown {content} h1="h2">
135-
136-
<!-- use a custom component instead of divs -->
137-
138-
{#snippet div({ props, children })}
139-
<MyFancyDiv {...props}>{@render children()}</MyFancyDiv>
140-
{/snippet}
131+
<!-- use a custom component instead of divs -->
132+
{#snippet div({ props, children })}
133+
<MyFancyDiv {...props}>{@render children()}</MyFancyDiv>
134+
{/snippet}
141135
</Markdown>
142-
\`\`\`
136+
```
143137

144138
## More info?
145139

0 commit comments

Comments
 (0)