math off by default, enable with latex_maths flag

pull/21833/head
Aleks Kissinger 2020-09-20 15:07:12 +01:00
parent e78734bbf6
commit 428a6b94ff
2 changed files with 5 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import EMOJIBASE_REGEX from 'emojibase-regex';
import url from 'url';
import katex from 'katex';
import { AllHtmlEntities } from 'html-entities';
import SdkConfig from './SdkConfig';
import {MatrixClientPeg} from './MatrixClientPeg';
import {tryTransformPermalinkToLocalHref} from "./utils/permalinks/Permalinks";
@ -50,6 +51,7 @@ const ZWJ_REGEX = new RegExp("\u200D|\u2003", "g");
// Regex pattern for whitespace characters
const WHITESPACE_REGEX = new RegExp("\\s", "g");
const BIGEMOJI_REGEX = new RegExp(`^(${EMOJIBASE_REGEX.source})+$`, 'i');
const COLOR_REGEX = /^#[0-9a-fA-F]{6}$/;
@ -411,7 +413,7 @@ export function bodyToHtml(content: IContent, highlights: string[], opts: IOpts
if (isHtmlMessage) {
isDisplayedWithHtml = true;
safeBody = sanitizeHtml(formattedBody, sanitizeParams);
if (true) { // TODO: add katex setting
if (SdkConfig.get()['latex_maths']) {
const mathDelimiters = [
{ left: "<div data-mx-maths=\"", right: "\">.*?</div>", display: true },
{ left: "<span data-mx-maths=\"", right: "\">.*?</span>", display: false }

View File

@ -19,6 +19,7 @@ import Markdown from '../Markdown';
import {makeGenericPermalink} from "../utils/permalinks/Permalinks";
import EditorModel from "./model";
import { AllHtmlEntities } from 'html-entities';
import SdkConfig from '../SdkConfig';
export function mdSerialize(model: EditorModel) {
return model.parts.reduce((html, part) => {
@ -41,7 +42,7 @@ export function mdSerialize(model: EditorModel) {
export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} = {}) {
var md = mdSerialize(model);
if (true) { // TODO: add katex setting
if (SdkConfig.get()['latex_maths']) {
const mathDelimiters = [ // TODO: make customizable
{ left: "\\$\\$\\$", right: "\\$\\$\\$", display: true },
{ left: "\\$\\$", right: "\\$\\$", display: false }