mirror of https://github.com/vector-im/riot-web
math off by default, enable with latex_maths flag
parent
e78734bbf6
commit
428a6b94ff
|
@ -28,6 +28,7 @@ import EMOJIBASE_REGEX from 'emojibase-regex';
|
||||||
import url from 'url';
|
import url from 'url';
|
||||||
import katex from 'katex';
|
import katex from 'katex';
|
||||||
import { AllHtmlEntities } from 'html-entities';
|
import { AllHtmlEntities } from 'html-entities';
|
||||||
|
import SdkConfig from './SdkConfig';
|
||||||
|
|
||||||
import {MatrixClientPeg} from './MatrixClientPeg';
|
import {MatrixClientPeg} from './MatrixClientPeg';
|
||||||
import {tryTransformPermalinkToLocalHref} from "./utils/permalinks/Permalinks";
|
import {tryTransformPermalinkToLocalHref} from "./utils/permalinks/Permalinks";
|
||||||
|
@ -50,6 +51,7 @@ const ZWJ_REGEX = new RegExp("\u200D|\u2003", "g");
|
||||||
// Regex pattern for whitespace characters
|
// Regex pattern for whitespace characters
|
||||||
const WHITESPACE_REGEX = new RegExp("\\s", "g");
|
const WHITESPACE_REGEX = new RegExp("\\s", "g");
|
||||||
|
|
||||||
|
|
||||||
const BIGEMOJI_REGEX = new RegExp(`^(${EMOJIBASE_REGEX.source})+$`, 'i');
|
const BIGEMOJI_REGEX = new RegExp(`^(${EMOJIBASE_REGEX.source})+$`, 'i');
|
||||||
|
|
||||||
const COLOR_REGEX = /^#[0-9a-fA-F]{6}$/;
|
const COLOR_REGEX = /^#[0-9a-fA-F]{6}$/;
|
||||||
|
@ -411,7 +413,7 @@ export function bodyToHtml(content: IContent, highlights: string[], opts: IOpts
|
||||||
if (isHtmlMessage) {
|
if (isHtmlMessage) {
|
||||||
isDisplayedWithHtml = true;
|
isDisplayedWithHtml = true;
|
||||||
safeBody = sanitizeHtml(formattedBody, sanitizeParams);
|
safeBody = sanitizeHtml(formattedBody, sanitizeParams);
|
||||||
if (true) { // TODO: add katex setting
|
if (SdkConfig.get()['latex_maths']) {
|
||||||
const mathDelimiters = [
|
const mathDelimiters = [
|
||||||
{ left: "<div data-mx-maths=\"", right: "\">.*?</div>", display: true },
|
{ left: "<div data-mx-maths=\"", right: "\">.*?</div>", display: true },
|
||||||
{ left: "<span data-mx-maths=\"", right: "\">.*?</span>", display: false }
|
{ left: "<span data-mx-maths=\"", right: "\">.*?</span>", display: false }
|
||||||
|
|
|
@ -19,6 +19,7 @@ import Markdown from '../Markdown';
|
||||||
import {makeGenericPermalink} from "../utils/permalinks/Permalinks";
|
import {makeGenericPermalink} from "../utils/permalinks/Permalinks";
|
||||||
import EditorModel from "./model";
|
import EditorModel from "./model";
|
||||||
import { AllHtmlEntities } from 'html-entities';
|
import { AllHtmlEntities } from 'html-entities';
|
||||||
|
import SdkConfig from '../SdkConfig';
|
||||||
|
|
||||||
export function mdSerialize(model: EditorModel) {
|
export function mdSerialize(model: EditorModel) {
|
||||||
return model.parts.reduce((html, part) => {
|
return model.parts.reduce((html, part) => {
|
||||||
|
@ -41,7 +42,7 @@ export function mdSerialize(model: EditorModel) {
|
||||||
export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} = {}) {
|
export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} = {}) {
|
||||||
var md = mdSerialize(model);
|
var md = mdSerialize(model);
|
||||||
|
|
||||||
if (true) { // TODO: add katex setting
|
if (SdkConfig.get()['latex_maths']) {
|
||||||
const mathDelimiters = [ // TODO: make customizable
|
const mathDelimiters = [ // TODO: make customizable
|
||||||
{ left: "\\$\\$\\$", right: "\\$\\$\\$", display: true },
|
{ left: "\\$\\$\\$", right: "\\$\\$\\$", display: true },
|
||||||
{ left: "\\$\\$", right: "\\$\\$", display: false }
|
{ left: "\\$\\$", right: "\\$\\$", display: false }
|
||||||
|
|
Loading…
Reference in New Issue