All Projects → lucpotage → Vue Katex

lucpotage / Vue Katex

Licence: mit
Vue plugin for KaTeX

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Vue Katex

purple-pi
💜 LaTeX math wherever you want
Stars: ✭ 31 (-62.2%)
Mutual labels:  katex
Jupyter Renderers
Renderers and renderer extensions for JupyterLab
Stars: ✭ 395 (+381.71%)
Mutual labels:  katex
Yii2 Quill
Yii 2 implementation of Quill, modern WYSIWYG editor
Stars: ✭ 52 (-36.59%)
Mutual labels:  katex
vuepress-theme-gungnir
A blog theme for VuePress 2.
Stars: ✭ 160 (+95.12%)
Mutual labels:  katex
React Katex
Display math in TeX with KaTeX and ReactJS
Stars: ✭ 345 (+320.73%)
Mutual labels:  katex
Mdmath
LaTeX Math for Markdown inside of Visual Studio Code.
Stars: ✭ 675 (+723.17%)
Mutual labels:  katex
vue-showdowns-editor
A markdown editor using codemirror and previewer using @jhuix/showdowns for Vue.js.
Stars: ✭ 27 (-67.07%)
Mutual labels:  katex
Article
Components for interactive scientific writing, reactive documents and explorable explanations.
Stars: ✭ 77 (-6.1%)
Mutual labels:  katex
Liandi
📕 一款桌面端的 Markdown 块级引用和双向链接笔记应用,支持 Windows、Mac 和 Linux。A desktop Markdown Block-Reference and Bidirectional-Link note-taking application, supports Windows, Mac and Linux.
Stars: ✭ 354 (+331.71%)
Mutual labels:  katex
Prosemirror Math
Schema and plugins for "first-class" math support in ProseMirror!
Stars: ✭ 43 (-47.56%)
Mutual labels:  katex
Noteless
A Markdown-based note-taking app for mobile devices.
Stars: ✭ 302 (+268.29%)
Mutual labels:  katex
Qilin App
Fully hackable text editor developed for exact sciences with built-in KaTeX and AsciiMath support. Extensible via plugins and themes. Exportable as HTML, PDF and GFM.
Stars: ✭ 336 (+309.76%)
Mutual labels:  katex
Ngx Markdown
Angular markdown component/directive/pipe/service to parse static, dynamic or remote content to HTML with syntax highlight
Stars: ✭ 687 (+737.8%)
Mutual labels:  katex
pseudocode.js
Beautiful pseudocode for the Web
Stars: ✭ 132 (+60.98%)
Mutual labels:  katex
Hepek
Web content generators in Scala. Intuitive, scalable, powerful.
Stars: ✭ 69 (-15.85%)
Mutual labels:  katex
react-latex-next
Render LaTeX in React apps
Stars: ✭ 18 (-78.05%)
Mutual labels:  katex
Franklin.jl
(yet another) static site generator. Simple, customisable, fast, maths with KaTeX, code evaluation, optional pre-rendering, in Julia.
Stars: ✭ 413 (+403.66%)
Mutual labels:  katex
Spmathkit
Render math exercises for your view. Contains the rendering of mathematical formulas and mathematical graphics, as well as the general text
Stars: ✭ 81 (-1.22%)
Mutual labels:  katex
Jekyll Katex
Jekyll plugin for easy server-side math rendering via KaTeX
Stars: ✭ 73 (-10.98%)
Mutual labels:  katex
Dominhhai.github.io
My Blog
Stars: ✭ 8 (-90.24%)
Mutual labels:  katex

vue-katex

KaTeX enables fast math typesetting for the web. vue-katex is a lightweight plugin introduces a simple way to use KaTeX in your Vue app. Enjoy! 🙂

NPM version License: MIT Build Status codecov

Installation

Install vue-katex with katex as a peer dependency

# With NPM
npm i vue-katex katex -P

# With Yarn
yarn add vue-katex katex

As explained in the KaTeX documentation, you must also add the related stylesheet.

<style>
  @import "../node_modules/katex/dist/katex.min.css";
</style>

or

import 'katex/dist/katex.min.css';

Getting started

In your script entry point:

import Vue from 'vue';
import VueKatex from 'vue-katex';
import 'katex/dist/katex.min.css';

Vue.use(VueKatex, {
  globalOptions: {
    //... Define globally applied KaTeX options here
  }
});

Now you are all setup to use the plugin.

Usage

There are two ways to use vue-katex, using the KatexElement component or using the v-katex directive.

Global Options

Options applied globally through the plugin will be merged with any options applied locally to the v-katex directive or KatexElement. Locally applied options have a higher precedence and will override globally applied options, the exception to this is any KaTeX option of the type object or array. These will be merged with the resultant option containing all global and local keys or elements.

Using the katex directive

In your template (don't forget to escape all backslashes):

<div v-katex="'\\frac{a_i}{1+x}'"></div>

To render the math in display mode:

<div v-katex:display="'\\frac{a_i}{1+x}'"></div>

To add KaTeX options, use an object literal instead:

<div v-katex="{ expression: '\\frac{a_i}{1+x}', options: { throwOnError: false }}"></div>

Using the katex directive with auto-render

<div v-katex:auto>
  \(\frac{a_i}{1+x}\)
</div>

Options can be applied as follows

<div v-katex:auto="{ options }">
  \(\frac{a_i}{1+x}\)
</div>

See KaTeX documentation for auto-render for more information.

Using the KatexElement component

<katex-element expression="'\\frac{a_i}{1+x}'"/>

Through props KatexElement supports all of the same options that KaTeX supports.

Props

expression

Type: String Required

A TeX expression to be displayed.

display-mode

Type: Boolean Default: false

If true the math will be rendered in display mode, which will put the math in display style (so \int and \sum are large, for example), and will center the math on the page on its own line. If false the math will be rendered in inline mode.

throw-on-error

Type: Boolean Default: false

If true, KaTeX will throw a ParseError when it encounters an unsupported command or invalid LaTeX. If false, KaTeX will render unsupported commands as text, and render invalid LaTeX as its source code with hover text giving the error, in the color given by errorColor.

error-color="#CC0000"

Type: String Default: #CC0000

A color string given in the format "#XXX" or "#XXXXXX". This option determines the color that unsupported commands and invalid LaTeX are rendered in when throwOnError is set to false.

macros

Type: Object Default: null

A collection of custom macros. Each macro is a property with a name like \name (written "\\name" in JavaScript) which maps to a string that describes the expansion of the macro, or a function that accepts an instance of MacroExpander as first argument and returns the expansion as a string. MacroExpander is an internal API and subject to non-backwards compatible changes. See src/macros.js for its usage. Single-character keys can also be included in which case the character will be redefined as the given macro (similar to TeX active characters). This object will be modified if the LaTeX code defines its own macros via \gdef, which enables consecutive calls to KaTeX to share state.

color-is-text-color

Type: Boolean Default: false

If true, \color will work like LaTeX's \textcolor, and take two arguments (e.g., \color{blue}{hello}), which restores the old behavior of KaTeX (pre-0.8.0). If false, \color will work like LaTeX's \color, and take one argument (e.g., \color{blue}hello). In both cases, \textcolor works as in LaTeX (e.g., \textcolor{blue}{hello}).

max-size="Infinity"

Type: Number Default: Infinity

All user-specified sizes, e.g. in \rule{500em}{500em}, will be capped to maxSize ems. If set to Infinity (the default), users can make elements and spaces arbitrarily large.

max-expand="1000"

Type: Number Default: 1000

Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.

allowed-protocols="[]"

Type: String[] Default: ["http", "https", "mailto", "_relative"]

Allowed protocols in \href. Use _relative to allow relative urls, and * to allow all protocols.

strict

Type: [Boolean, String, Function] Default: "warn"

If false or "ignore", allow features that make writing LaTeX convenient but are not actually supported by (Xe)LaTeX (similar to MathJax). If true or "error" (LaTeX faithfulness mode), throw an error for any such transgressions. If "warn" (the default), warn about such behavior via console.warn. Provide a custom function handler(errorCode, errorMsg, token) to customize behavior depending on the type of transgression (summarized by the string code errorCode and detailed in errorMsg); this function can also return "ignore", "error", or "warn" to use a built-in behavior. A list of such features and their errorCode:
  • "unknownSymbol": Use of unknown Unicode symbol, which will likely also lead to warnings about missing character metrics, and layouts may be incorrect (especially in terms of vertical heights).
  • "unicodeTextInMathMode": Use of Unicode text characters in math mode.
  • "mathVsTextUnits": Mismatch of math vs. text commands and units/mode.
  • "commentAtEnd": Use of % comment without a terminating newline. LaTeX would thereby comment out the end of math mode (e.g. $), causing an error. A second category of errorCodes never throw errors, but their strictness affects the behavior of KaTeX
  • "newLineInDisplayMode": Use of \ or \newline in display mode (outside an array/tabular environment). In strict mode, no line break results, as in LaTeX.

See also: KaTeX Documentation

License

vue-katex is released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].