Skip to content

Commit 8f87b2a

Browse files
committed
doc: Add code example.
1 parent 24af229 commit 8f87b2a

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,47 @@ export default function App() {
9494
> - ~~`@codemirror/legacy-modes/mode/sql`~~ => [`@codemirror/lang-sql`](https://www.npmjs.com/package/@codemirror/lang-sql)
9595
> - ~~`@codemirror/legacy-modes/mode/xml`~~ => [`@codemirror/lang-xml`](https://www.npmjs.com/package/@codemirror/lang-xml)
9696
97+
### Markdown Example
98+
99+
Markdown code is automatically highlighted.
100+
101+
[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?logo=codesandbox)](https://codesandbox.io/embed/react-codemirror-example-codemirror-6-markdown-auto-languages-iudnj?fontsize=14&hidenavigation=1&theme=dark)
102+
103+
```jsx
104+
import CodeMirror from '@uiw/react-codemirror';
105+
import { markdown, markdownLanguage } from '@codemirror/lang-markdown';
106+
import { languages } from '@codemirror/language-data';
107+
108+
const code = `## Title
109+
110+
\`\`\`jsx
111+
function Demo() {
112+
return <div>demo</div>
113+
}
114+
\`\`\`
115+
116+
\`\`\`bash
117+
# Not dependent on uiw.
118+
npm install @codemirror/lang-markdown --save
119+
npm install @codemirror/language-data --save
120+
\`\`\`
121+
122+
[weisit ulr](https://uiwjs.github.io/react-codemirror/)
123+
124+
\`\`\`go
125+
package main
126+
import "fmt"
127+
func main() {
128+
fmt.Println("Hello, 世界")
129+
}
130+
\`\`\`
131+
`;
132+
133+
export default function App() {
134+
return <CodeMirror value={code} extensions={[markdown({ base: markdownLanguage, codeLanguages: languages })]} />;
135+
}
136+
```
137+
97138
## Support Hook
98139

99140
[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?logo=codesandbox)](https://codesandbox.io/embed/react-codemirror-example-codemirror-6-hook-yr4vg?fontsize=14&hidenavigation=1&theme=dark)

0 commit comments

Comments
 (0)