返回 marp
Pre.tsx
1 import { CodeBlock } from '../CodeBlock'
2
3 export const Pre: React.FC = (props) => {
4 if (props['data-code'] === undefined) return <pre {...props} />
5
6 return (
7 <CodeBlock
8 className="sm:mx-auto sm:w-11/12 lg:w-5/6"
9 language={props['data-language']}
10 copyButton
11 >
12 {props['data-code']}
13 </CodeBlock>
14 )
15 }
16
17 export const toHastCodeHandler = (h, { position, lang, value, marp }) => {
18 if (marp) {
19 return h(position, 'marp-slides', {
20 'data-comments': JSON.stringify(marp.comments),
21 'data-css': marp.css,
22 'data-html': JSON.stringify(marp.html),
23 'data-fonts': JSON.stringify(marp.fonts),
24 })
25 }
26
27 return h(
28 position,
29 'pre',
30 { 'data-code': value, 'data-language': lang?.trim() },
31 []
32 )
33 }
34
34 lines Plain Text