Use LaTeX delimiters by default, add /tex command

Since parsing for $'s as maths delimiters is tricky, switch the default
to \(...\) for inline and \[...\] for display maths as it is used in
LaTeX. Add /tex command to explicitly parse in TeX mode, which uses
$...$ for inline and $$...$$ for display maths.

Signed-off-by: Sven Mäder <maeder@phys.ethz.ch>
This commit is contained in:
Sven Mäder 2020-12-20 23:14:56 +01:00
parent fa02630c4e
commit 78b3f50bfd
4 changed files with 99 additions and 26 deletions

View file

@ -48,6 +48,7 @@ import SettingsStore from "./settings/SettingsStore";
import {UIFeature} from "./settings/UIFeature";
import {CHAT_EFFECTS} from "./effects"
import CallHandler from "./CallHandler";
import {markdownSerializeIfNeeded} from './editor/serialize';
// XXX: workaround for https://github.com/microsoft/TypeScript/issues/31816
interface HTMLInputEvent extends Event {
@ -223,6 +224,23 @@ export const Commands = [
},
category: CommandCategories.messages,
}),
new Command({
command: 'tex',
args: '<message>',
description: _td('Sends a message in TeX mode, using $ and $$ delimiters for maths'),
runFn: function(roomId, args) {
if (SettingsStore.getValue("feature_latex_maths")) {
if (args) {
let html = markdownSerializeIfNeeded(args, {forceHTML: false}, {forceTEX: true});
return success(MatrixClientPeg.get().sendHtmlMessage(roomId, args, html));
}
return reject(this.getUsage());
} else {
return reject("Render LaTeX maths in messages needs to be enabled in Labs");
}
},
category: CommandCategories.messages,
}),
new Command({
command: 'ddg',
args: '<query>',