Socket
Book a DemoInstallSign in
Socket

lang-tex

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lang-tex

TeX extension for CodeMirror 6

0.0.3
latest
Source
npmnpm
Version published
Weekly downloads
3
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

lang-tex

This is the TeX extension for CodeMirror 6.

Since TeX can change its notation during parsing, we can't expect any semantic meaning in any given command. However, there are a lot of best practices with TeX, so this project, along with lezer-tex, are based on these best practices.

Usage

Syntax

For the syntax extension, you must call texSyntax:

import { texSyntax } from "lang-tex";
const syntax = texSyntax();

It can take an optional object that specifies what TagSystem to use via the tagSystem key.

Remark: The tag system must extend the default CodeMirror tag system. By default, we use our TeX tag system, as opposed to the default CodeMirror tag system.

Highlighting

We currently provide a light theme extension accessible via texLightTheme. In order to use this theme however, the tag system must be our TeX tag system. You can create your own theme by using the highlighter function of our TeXTagSystem like so:

import { TeXTagSystem } from "lang-tex";
const highlighter = TeXTagSystem.highlighter(...ReactCSSStyleLikeObject)

Autocomplete

We currently only provide MathJax snippets. You can provide your own by following the CodeMirror autocomplete module docs.

MVP:

import { mathjaxSnippets, texSyntax, TeXTagSystem } from "../dist";
import { autocompletion } from "@codemirror/next/autocomplete";

// You must declare the syntax as a variable
const syntax = texSyntax();

// Adding the mathjax snippets to the syntax.
const texSupport = [syntax, syntax.languageData.of({ autocomplete: mathjaxSnippets })];

// DON'T FORGET THE `autocomplete` EXTENSION ITSELF!
const autocompleteExt = [autocompletion()].concat(texSupport)

Suggestions?

Since TeX can be used everywhere, we welcome suggestions for specific syntax with TeX (e.g. tikzpicture syntax). You must provide an explicit BNF grammar (or BNF-like grammar).

Keywords

tex

FAQs

Package last updated on 18 Dec 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.