MCPcopy Create free account
hub / github.com/editablejs/editable / runmode

Function runmode

packages/plugins/codeblock/src/serializer/html.ts:18–34  ·  view source on GitHub ↗
(
  textContent: string,
  language: Language,
  highlighter: Highlighter,
  callback: (text: string, style: string, from: number, to: number) => void,
  options?: Record<string, any>,
)

Source from the content-addressed store, hash-verified

16} from '../constants'
17
18export function runmode(
19 textContent: string,
20 language: Language,
21 highlighter: Highlighter,
22 callback: (text: string, style: string, from: number, to: number) => void,
23 options?: Record<string, any>,
24) {
25 const tree = language.parser.parse(textContent)
26 let pos = 0
27 highlightTree(tree, highlighter, (from, to, classes) => {
28 from > pos && callback(textContent.slice(pos, from), '', pos, from)
29
30 callback(textContent.slice(from, to), classes, from, to)
31 pos = to
32 })
33 pos != tree.length && callback(textContent.slice(pos, tree.length), '', pos, tree.length)
34}
35export interface CodeBlockHTMLSerializerWithOptions extends HTMLSerializerWithOptions {
36 editor: Editor
37}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…