Skip to content

Browser (EN)

bhsd edited this page Feb 12, 2024 · 5 revisions

Other Languages

Introduction

A simplified API is provided for browsers, which does not support modifying the syntax tree. In general, it is recommended to use the various extensions listed below rather than direct use.

Direct use

If you are using WikiParser-Node through extensions, skip this section.

You can download the code through CDN, such as:

<script src="//cdn.jsdelivr.net/npm/wikiparser-node@browser"></script>

or

<script src="//unpkg.com/wikiparser-node@browser"></script>

This script will add a global variable Parser.

Extensions

Base

This is the base extension, and is also a dependency of other extensions. You can download the code through CDN (it is recommended to use jsDelivr to combine multiple extensions), such as:

<script src="//cdn.jsdelivr.net/npm/wikiparser-node@browser/extensions/dist/base.min.js"></script>

or

<script src="//unpkg.com/wikiparser-node@browser/extensions/dist/base.js"></script>

This script will add a global variable wikiparse, and its methods are documented here.

Highlight

This extension adds a highlight method to the global variable wikiparse, which can be used to highlight static code. You can test the effect here. You can download the code through CDN:

<script src="//cdn.jsdelivr.net/combine/npm/wikiparser-node@browser/extensions/dist/base.min.js,npm/wikiparser-node@browser/extensions/dist/highlight.min.js"></script>

Editor

This extension adds an edit method to the global variable wikiparse, which can be used to highlight text boxes. You can test the effect here. You can download the code through CDN:

<script src="//cdn.jsdelivr.net/combine/npm/wikiparser-node@browser/extensions/dist/base.min.js,npm/wikiparser-node@browser/extensions/dist/editor.min.js"></script>

Lint

This extension adds a Linter constructor to the global variable wikiparse, which can be used to report grammar errors. You can test the effect here. You can download the code through CDN:

<script src="//cdn.jsdelivr.net/combine/npm/wikiparser-node@browser/extensions/dist/base.min.js,npm/wikiparser-node@browser/extensions/dist/lint.min.js"></script>
Clone this wiki locally