From 14aaa10bf35929504afce06067d1cb89be2f865b Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Wed, 4 Aug 2021 21:41:34 +0200 Subject: [PATCH] Implement latex highlighting for Latex in codable --- ts/editor/codable.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ts/editor/codable.ts b/ts/editor/codable.ts index 5e4f778f2..2774a4faf 100644 --- a/ts/editor/codable.ts +++ b/ts/editor/codable.ts @@ -2,7 +2,9 @@ // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import * as CodeMirror from "codemirror/lib/codemirror"; +import "codemirror/mode/python/python"; import "codemirror/mode/htmlmixed/htmlmixed"; +import "codemirror/mode/stex/stex"; import "codemirror/addon/fold/foldcode"; import "codemirror/addon/fold/foldgutter"; import "codemirror/addon/fold/xml-fold"; @@ -11,8 +13,22 @@ import "codemirror/addon/edit/closetag.js"; import { inCodable } from "./toolbar"; +const latex = { + name: "stex", + inMathMode: true, +}; + +const htmlanki = { + name: "htmlmixed", + tags: { + "anki-mathjax-inline": [[null, null, latex]], + "anki-mathjax-block": [[null, null, latex]], + "anki-mathjax-chemistry": [[null, null, latex]], + }, +}; + const codeMirrorOptions = { - mode: "htmlmixed", + mode: htmlanki, theme: "monokai", lineNumbers: true, lineWrapping: true,