mirror of
https://github.com/MisskeyIO/misskey
synced 2024-11-24 15:16:21 +09:00
Change math syntax (#3280)
This commit is contained in:
parent
cb0874f15a
commit
3fc70996e2
@ -9,7 +9,7 @@ export type TextElementMath = {
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^\$(.+?)\$/);
|
||||
const match = text.match(/^\\\((.+?)\\\)/);
|
||||
if (!match) return null;
|
||||
const math = match[0];
|
||||
return {
|
||||
|
@ -13,11 +13,11 @@ describe('Text', () => {
|
||||
const tokens = analyze('@himawari @hima_sub@namori.net お腹ペコい :cat: #yryr');
|
||||
assert.deepEqual([
|
||||
{ type: 'mention', content: '@himawari', canonical: '@himawari', username: 'himawari', host: null },
|
||||
{ type: 'text', content: ' '},
|
||||
{ type: 'text', content: ' ' },
|
||||
{ type: 'mention', content: '@hima_sub@namori.net', canonical: '@hima_sub@namori.net', username: 'hima_sub', host: 'namori.net' },
|
||||
{ type: 'text', content: ' お腹ペコい ' },
|
||||
{ type: 'emoji', content: ':cat:', name: 'cat'},
|
||||
{ type: 'text', content: ' '},
|
||||
{ type: 'emoji', content: ':cat:', name: 'cat' },
|
||||
{ type: 'text', content: ' ' },
|
||||
{ type: 'hashtag', content: '#yryr', hashtag: 'yryr' }
|
||||
], tokens);
|
||||
});
|
||||
@ -266,7 +266,7 @@ describe('Text', () => {
|
||||
|
||||
it('math', () => {
|
||||
const fomula = 'x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.';
|
||||
const text = `$${fomula}$`;
|
||||
const text = `\\(${fomula}\\)`;
|
||||
const tokens = analyze(text);
|
||||
assert.deepEqual([
|
||||
{ type: 'math', content: text, formula: fomula }
|
||||
|
Loading…
Reference in New Issue
Block a user