MCPcopy Index your code
hub / github.com/pomber/code-surfer / readStepFromElement

Function readStepFromElement

packs/code-surfer/src/step-reader.js:7–22  ·  view source on GitHub ↗
(element)

Source from the content-addressed store, hash-verified

5}
6
7export 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}

Callers 2

getColumnsFromChildrenFunction · 0.90
getStepsFromChildrenFunction · 0.90

Calls 2

parseMetastringFunction · 0.90
isCodeFunction · 0.85

Tested by

no test coverage detected