(element)
| 5 | } |
| 6 | |
| 7 | export function readStepFromElement(element) { |
| 8 | if (!isCode(element)) { |
| 9 | throw new Error( |
| 10 | "Invalid element inside <CodeSurfer/>. Make sure to add empty lines (no spaces) before and after each codeblock." |
| 11 | ); |
| 12 | } |
| 13 | |
| 14 | const { props } = element.props.children; |
| 15 | |
| 16 | const className = props.className && props.className.split(" ")[0]; |
| 17 | return { |
| 18 | code: props.children, |
| 19 | lang: className && className.substring("language-".length), |
| 20 | ...parseMetastring(props.metastring) |
| 21 | }; |
| 22 | } |
no test coverage detected