mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 03:08:40 +00:00
Add documentation regarding importing the module (#1768)
This commit is contained in:
36
docs/node.md
36
docs/node.md
@@ -2,7 +2,8 @@
|
||||
id: node
|
||||
title: Node.js
|
||||
---
|
||||
## npm
|
||||
## Installation
|
||||
### npm
|
||||
Install with `npm`:
|
||||
|
||||
```bash
|
||||
@@ -11,7 +12,7 @@ npm install katex
|
||||
npm install -g katex
|
||||
```
|
||||
|
||||
## Yarn
|
||||
### Yarn
|
||||
Install with `Yarn`:
|
||||
|
||||
```bash
|
||||
@@ -20,8 +21,7 @@ yarn add katex
|
||||
yarn global add katex
|
||||
```
|
||||
|
||||
## Building from Source
|
||||
|
||||
### Building from Source
|
||||
To build you will need Git, Node.js 6.9 or later, and Yarn.
|
||||
|
||||
Clone a copy of the GitHub source repository:
|
||||
@@ -36,5 +36,33 @@ yarn
|
||||
yarn build
|
||||
```
|
||||
|
||||
If you'd like to use the built KaTeX in other projects, install the package by
|
||||
specifying the path:
|
||||
```bash
|
||||
yarn add /path/to/KaTeX
|
||||
# or using npm
|
||||
npm install /path/to/KaTeX
|
||||
```
|
||||
|
||||
> You can manually download the package and source code from
|
||||
[GitHub releases](https://github.com/Khan/KaTeX/releases).
|
||||
|
||||
## Importing
|
||||
KaTeX is exported as a CommonJS module, which can be imported using `require`:
|
||||
```js
|
||||
const katex = require('katex');
|
||||
```
|
||||
|
||||
If you're using a module loader, transpiler, or bundler that supports interoperability
|
||||
between ECMAScript module and CommonJS module, you can use `import`:
|
||||
```js
|
||||
import katex from 'katex';
|
||||
```
|
||||
|
||||
KaTeX also provides an ECMAScript module:
|
||||
```js
|
||||
import katex from 'katex/dist/katex.mjs'
|
||||
```
|
||||
|
||||
> The ES module contains ES6 syntaxes and features, and may need transpiling to
|
||||
use in old environments:
|
||||
|
Reference in New Issue
Block a user