MCPcopy Create free account
hub / github.com/CodinGame/monaco-vscode-api / parseMarkdown

Function parseMarkdown

demo/src/features/testing.ts:23–55  ·  view source on GitHub ↗
(
    text: string,
    events: {
      onTest(range: vscode.Range, a: number, operator: string, b: number, expected: number): void
      onHeading(range: vscode.Range, name: string, depth: number): void
    }
  )

Source from the content-addressed store, hash-verified

21 const headingRe = /^(#+)\s*(.+)$/
22
23 const parseMarkdown = (
24 text: string,
25 events: {
26 onTest(range: vscode.Range, a: number, operator: string, b: number, expected: number): void
27 onHeading(range: vscode.Range, name: string, depth: number): void
28 }
29 ): void => {
30 const lines = text.split('\n')
31
32 for (let lineNo = 0; lineNo < lines.length; lineNo++) {
33 const line = lines[lineNo]!
34 const test = testRe.exec(line)
35 if (test != null) {
36 const [, a, operator, b, expected] = test
37 const range = new api.Range(
38 new api.Position(lineNo, 0),
39 new api.Position(lineNo, test[0].length)
40 )
41 events.onTest(range, Number(a), operator!, Number(b), Number(expected))
42 continue
43 }
44
45 const heading = headingRe.exec(line)
46 if (heading != null) {
47 const [, pounds, name] = heading
48 const range = new api.Range(
49 new api.Position(lineNo, 0),
50 new api.Position(lineNo, line.length)
51 )
52 events.onHeading(range, name!, pounds!.length)
53 }
54 }
55 }
56
57 const textDecoder = new TextDecoder('utf-8')
58

Callers 1

updateFromContentsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…