MMOframework
Pourquoi l'IA Playground Bibliothèques Documentation Rechercher Agence
FR EN
Index

Highlighter

MMO.git · 1 symbole · générée le 27 Oct 2026

class

Highlighter

Highlighter.js:16

The colours of a file's code, line by line, with Prism: the file is coloured whole and then cut into lines, so a comment or a string spanning several lines keeps its colour on each of them. Prism is loaded the first time, from MMO.git.config.prism, when the page has none.

class MMO.git.Highlighter
Espace de noms
MMO.git
What it gives is html made from the text by Prism, which escapes it, or by `MMO.git.escape`: never the text itself.
const lines = await MMO.git.Highlighter.lines("<?php\n a\n b *\/\n", 'php'); //['<span class="token delimiter important">&lt;?php</span>', '<span class="token comment"> a</span>', ...]

Index

loading static
load() static
lines(text, language) static async
line(text, language) staticOne line, alone: for a line whose file is not there (too long, or not sent).
Split(html, count) staticCut Prism's html into lines: the spans still open at the end of a line are closed there, and opened again on the next one.
mark(html, ranges) staticWrap the characters of $ranges in <mark>, inside a line's html: around its text only, never across a tag.

Propriétés1

Méthodes5

load()

staticHighlighter.js:23
static load()
retournePromise<boolean>whether Prism is there, loading it the first time if the page has none

lines(text, language)

staticasyncHighlighter.js:44
static async lines(text, language)
text?stringa whole file
language?stringPrism's (MMO.git.language); null: no colours
retournePromise<Array<string>>each line's html, without its end of line

line(text, language)

staticHighlighter.js:57

One line, alone: for a line whose file is not there (too long, or not sent).

static line(text, language)
textstring
language?string
retournestring

Split(html, count)

staticHighlighter.js:69

Cut Prism's html into lines: the spans still open at the end of a line are closed there, and opened again on the next one.

static Split(html, count)
htmlstring
countnumberhow many lines there are
retourneArray<string>

mark(html, ranges)

staticHighlighter.js:95

Wrap the characters of $ranges in <mark>, inside a line's html: around its text only, never across a tag.

static mark(html, ranges)
htmlstringa line, as lines gives it
ranges?Array<Array<number>>[start, end) of the line's text (MMO.git.TextDiff.words)
retournestring