Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/frugal/docs/dep/prism.ts>highlight

A frugal web framework
Go to Latest
function highlight
import { highlight } from "https://deno.land/x/frugal@0.5.0/docs/dep/prism.ts";

Low-level function, only use if you know what you’re doing. It accepts a string of text as input and the language definitions to use, and returns a string with the HTML produced.

The following hooks will be run:

  1. before-tokenize
  2. after-tokenize
  3. wrap: On each Prism.Token.

Examples

Prism.highlight('var foo = true;', Prism.languages.js, 'js');

Parameters

text: string

A string with the code to be highlighted.

grammar: Grammar

An object containing the tokens to use.

Usually a language definition like Prism.languages.markup.

language: string

The name of the language definition passed to grammar.

Returns

string

The highlighted HTML.