latex math as labs setting
This commit is contained in:
parent
919a1a8125
commit
96742fc309
4 changed files with 12 additions and 5 deletions
|
@ -28,7 +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 SettingsStore from './settings/SettingsStore';
|
||||||
|
|
||||||
import {MatrixClientPeg} from './MatrixClientPeg';
|
import {MatrixClientPeg} from './MatrixClientPeg';
|
||||||
import {tryTransformPermalinkToLocalHref} from "./utils/permalinks/Permalinks";
|
import {tryTransformPermalinkToLocalHref} from "./utils/permalinks/Permalinks";
|
||||||
|
@ -412,7 +412,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 (SdkConfig.get()['latex_maths']) {
|
if (SettingsStore.getValue("feature_latex_maths")) {
|
||||||
const mathDelimiters = [
|
const mathDelimiters = [
|
||||||
{ pattern: "<div data-mx-maths=\"([^\"]*)\">(.|\\s)*?</div>", display: true },
|
{ pattern: "<div data-mx-maths=\"([^\"]*)\">(.|\\s)*?</div>", display: true },
|
||||||
{ pattern: "<span data-mx-maths=\"([^\"]*)\">(.|\\s)*?</span>", display: false },
|
{ pattern: "<span data-mx-maths=\"([^\"]*)\">(.|\\s)*?</span>", display: false },
|
||||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
||||||
|
|
||||||
import commonmark from 'commonmark';
|
import commonmark from 'commonmark';
|
||||||
import {escape} from "lodash";
|
import {escape} from "lodash";
|
||||||
import SdkConfig from './SdkConfig';
|
import SettingsStore from './settings/SettingsStore';
|
||||||
|
|
||||||
const ALLOWED_HTML_TAGS = ['sub', 'sup', 'del', 'u'];
|
const ALLOWED_HTML_TAGS = ['sub', 'sup', 'del', 'u'];
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ function is_math_node(node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_allowed_html_tag(node) {
|
function is_allowed_html_tag(node) {
|
||||||
if (SdkConfig.get()['latex_maths'] &&
|
if (SettingsStore.getValue("feature_latex_maths") &&
|
||||||
(is_math_node(node) ||
|
(is_math_node(node) ||
|
||||||
(node.literal.match(/^<\/?code>$/) && is_math_node(node.parent)))) {
|
(node.literal.match(/^<\/?code>$/) && is_math_node(node.parent)))) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -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 SettingsStore from '../settings/SettingsStore';
|
||||||
import SdkConfig from '../SdkConfig';
|
import SdkConfig from '../SdkConfig';
|
||||||
|
|
||||||
export function mdSerialize(model: EditorModel) {
|
export function mdSerialize(model: EditorModel) {
|
||||||
|
@ -42,7 +43,7 @@ export function mdSerialize(model: EditorModel) {
|
||||||
export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} = {}) {
|
export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} = {}) {
|
||||||
let md = mdSerialize(model);
|
let md = mdSerialize(model);
|
||||||
|
|
||||||
if (SdkConfig.get()['latex_maths']) {
|
if (SettingsStore.getValue("feature_latex_maths")) {
|
||||||
const displayPattern = (SdkConfig.get()['latex_maths_delims'] || {})['display_pattern'] ||
|
const displayPattern = (SdkConfig.get()['latex_maths_delims'] || {})['display_pattern'] ||
|
||||||
"\\$\\$\\$(([^$]|\\\\\\$)*)\\$\\$\\$";
|
"\\$\\$\\$(([^$]|\\\\\\$)*)\\$\\$\\$";
|
||||||
const inlinePattern = (SdkConfig.get()['latex_maths_delims'] || {})['inline_pattern'] ||
|
const inlinePattern = (SdkConfig.get()['latex_maths_delims'] || {})['inline_pattern'] ||
|
||||||
|
|
|
@ -116,6 +116,12 @@ export interface ISetting {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SETTINGS: {[setting: string]: ISetting} = {
|
export const SETTINGS: {[setting: string]: ISetting} = {
|
||||||
|
"feature_latex_maths": {
|
||||||
|
isFeature: true,
|
||||||
|
displayName: _td("LaTeX math in messages"),
|
||||||
|
supportedLevels: LEVELS_FEATURE,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
"feature_communities_v2_prototypes": {
|
"feature_communities_v2_prototypes": {
|
||||||
isFeature: true,
|
isFeature: true,
|
||||||
displayName: _td(
|
displayName: _td(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue