/
githubmirror
/
marktext
Обзор
Документация
Войти
/
githubmirror
/
marktext
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/muyajs/lib/parser/render/renderInlines/highlight.js
38 строк
896 B
Ran Luo
chore: convert repo to pnpm monorepo (packages/desktop, muyajs, website) (#4302)
29 май 2026, 05:25
Не верифицирован
29 май 2026, 05:25
565bfcd
Код
Авторство
О чём код?
import { union } from '../../../utils' // change text to highlight vdom export default function highlight(h, block, rStart, rEnd, token) { const { text } = block const { highlights } = token let result = [] const unions = [] let pos = rStart if (highlights) { for (const light of highlights) { const un = union({ start: rStart, end: rEnd }, light) if (un) unions.push(un) } } if (unions.length) { for (const u of unions) { const { start, end, active } = u const className = this.getHighlightClassName(active) if (pos < start) { result.push(text.substring(pos, start)) } result.push(h(`span.${className}`, text.substring(start, end))) pos = end } if (pos < rEnd) { result.push(block.text.substring(pos, rEnd)) } } else { result = [text.substring(rStart, rEnd)] } return result }