Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@myriaddreamin/highlighter-typst
Advanced tools
Readme
Usage with highlight.js
:
<!-- import as cjs, js bundled, wasm bundled -->
<script
id="script-main"
src="https://cdn.jsdelivr.net/npm/@myriaddreamin/highlighter-typst/dist/cjs/contrib/hljs/typst.bundle.js"
></script>
<!-- import as cjs, js not bundled, wasm bundled -->
<!-- <script id="script-main" src="https://cdn.jsdelivr.net/npm/@myriaddreamin/highlighter-typst/dist/cjs/contrib/hljs/typst-lite.bundle.js"></script> -->
<!-- import as esm, js bundled, wasm bundled -->
<!-- <script id="script-main" type="module" src="https://cdn.jsdelivr.net/npm/@myriaddreamin/highlighter-typst/dist/esm/contrib/hljs/typst.bundle.js"></script> -->
<!-- import as esm, js not bundled, wasm not bundled -->
<!-- <script id="script-main" type="module" src="https://cdn.jsdelivr.net/npm/@myriaddreamin/highlighter-typst/dist/esm/contrib/hljs/typst-lite.mjs"></script> -->
<!-- import as esm, js bundled, wasm not bundled -->
<!-- <script id="script-main" type="module" src="https://cdn.jsdelivr.net/npm/@myriaddreamin/highlighter-typst/dist/esm/contrib/hljs/typst-lite.bundle.js"></script> -->
<script>
const run = $typst$parserModule.then(() => {
hljs.registerLanguage(
'typst',
window.hljsTypst({ // TypstHljsOptions
codeBlockDefaultLanguage: 'typst',
}),
);
// esm
document.getElementById('script-main').onload = run;
// cjs
run();
</script>
Documentation for highlight.js
apis:
/**
* A function that constructs a language definition for hljs
* @param options options for the hljsTypst function.
* @returns a language definition for hljs.
* See {@link TypstHljsOptions} for more details.
*
* @example
*
* Default usage:
* ```ts
* hljs.registerLanguage('typst', window.hljsTypst());
* ```
*
* @example
*
* Don't handle code blocks:
* ```ts
* hljs.registerLanguage('typst', window.hljsTypst({
* handleCodeBlocks: false,
* }));
*
* @example
*
* Handle code blocks with a custom function:
* ```ts
* hljs.registerLanguage('typst', window.hljsTypst({
* handleCodeBlocks: (code, emitter) => {
* return false;
* });
* }));
* ```
*
* @example
*
* Set the default language for code blocks:
* ```ts
* hljs.registerLanguage('typst', window.hljsTypst({
* codeBlockDefaultLanguage: 'rust',
* }));
* ```
*/
export function hljsTypst(options?: TypstHljsOptions);
/**
* Options for the `hljsTypst` function.
* @param handleCodeBlocks - Whether to handle code blocks.
* Defaults to true.
* If set to false, code blocks will be rendered as plain code blocks.
* If set to true, a default handler will be used.
* If set to a function, the function will be used as the handler.
*
* When the `hljsTypst` has a code block handler, the code block will be called with the code block content and the emitter.
*
* If the handler return false, the code block will be still rendered as plain code blocks.
*
* @param codeBlockDefaultLanguage - The default language for code blocks.
* Defaults to undefined.
*/
export interface TypstHljsOptions {
handleCodeBlocks?: boolean | ((code: string, emitter: any) => /*handled*/ boolean);
codeBlockDefaultLanguage?: string;
}
FAQs
typst code highlighting support in web
The npm package @myriaddreamin/highlighter-typst receives a total of 1 weekly downloads. As such, @myriaddreamin/highlighter-typst popularity was classified as not popular.
We found that @myriaddreamin/highlighter-typst demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.