Add multiline math syntax
Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
This commit is contained in:
@@ -87,7 +87,13 @@ export default (tokens: MfmForest, mentionedRemoteUsers: INote['mentionedRemoteU
|
||||
return el;
|
||||
},
|
||||
|
||||
math(token) {
|
||||
mathInline(token) {
|
||||
const el = doc.createElement('code');
|
||||
el.textContent = token.node.props.formula;
|
||||
return el;
|
||||
},
|
||||
|
||||
mathBlock(token) {
|
||||
const el = doc.createElement('code');
|
||||
el.textContent = token.node.props.formula;
|
||||
return el;
|
||||
|
@@ -103,7 +103,8 @@ const mfm = P.createLanguage({
|
||||
r.blockCode,
|
||||
r.inlineCode,
|
||||
r.quote,
|
||||
r.math,
|
||||
r.mathInline,
|
||||
r.mathBlock,
|
||||
r.search,
|
||||
r.title,
|
||||
r.center,
|
||||
@@ -121,7 +122,7 @@ const mfm = P.createLanguage({
|
||||
r.mention,
|
||||
r.hashtag,
|
||||
r.emoji,
|
||||
r.math,
|
||||
r.mathInline,
|
||||
r.text
|
||||
).atLeast(1).tryParse(x), {})),
|
||||
//#endregion
|
||||
@@ -135,7 +136,7 @@ const mfm = P.createLanguage({
|
||||
r.mention,
|
||||
r.hashtag,
|
||||
r.emoji,
|
||||
r.math,
|
||||
r.mathInline,
|
||||
r.text
|
||||
).atLeast(1).tryParse(x), {})),
|
||||
//#endregion
|
||||
@@ -180,7 +181,7 @@ const mfm = P.createLanguage({
|
||||
r.mention,
|
||||
r.hashtag,
|
||||
r.emoji,
|
||||
r.math,
|
||||
r.mathInline,
|
||||
r.url,
|
||||
r.link,
|
||||
r.text
|
||||
@@ -274,10 +275,16 @@ const mfm = P.createLanguage({
|
||||
}),
|
||||
//#endregion
|
||||
|
||||
//#region Math
|
||||
math: r =>
|
||||
//#region Math (inline)
|
||||
mathInline: r =>
|
||||
P.regexp(/\\\((.+?)\\\)/, 1)
|
||||
.map(x => createLeaf('math', { formula: x })),
|
||||
.map(x => createLeaf('mathInline', { formula: x })),
|
||||
//#endregion
|
||||
|
||||
//#region Math (block)
|
||||
mathBlock: r =>
|
||||
P.regexp(/\\\[([\s\S]+?)\\\]/, 1)
|
||||
.map(x => createLeaf('mathBlock', { formula: x.trim() })),
|
||||
//#endregion
|
||||
|
||||
//#region Mention
|
||||
@@ -311,7 +318,7 @@ const mfm = P.createLanguage({
|
||||
r.emoji,
|
||||
r.url,
|
||||
r.link,
|
||||
r.math,
|
||||
r.mathInline,
|
||||
r.text
|
||||
).atLeast(1).tryParse(x), {})),
|
||||
//#endregion
|
||||
|
Reference in New Issue
Block a user