Add new MFM animation syntax
This commit is contained in:
parent
3d063c95d1
commit
d44cb7f256
5 changed files with 69 additions and 12 deletions
|
@ -77,6 +77,7 @@ export const mfmLanguage = P.createLanguage({
|
|||
r.jump,
|
||||
r.flip,
|
||||
r.twitch,
|
||||
r.shake,
|
||||
r.inlineCode,
|
||||
r.mathInline,
|
||||
r.mention,
|
||||
|
@ -124,6 +125,7 @@ export const mfmLanguage = P.createLanguage({
|
|||
jump: r => P.regexp(/<jump>(.+?)<\/jump>/, 1).map(x => createTree('jump', r.inline.atLeast(1).tryParse(x), {})),
|
||||
flip: r => P.regexp(/<flip>(.+?)<\/flip>/, 1).map(x => createTree('flip', r.inline.atLeast(1).tryParse(x), {})),
|
||||
twitch: r => P.regexp(/<twitch>(.+?)<\/twitch>/, 1).map(x => createTree('twitch', r.inline.atLeast(1).tryParse(x), {})),
|
||||
shake: r => P.regexp(/<shake>(.+?)<\/shake>/, 1).map(x => createTree('shake', r.inline.atLeast(1).tryParse(x), {})),
|
||||
center: r => r.startOfLine.then(P.regexp(/<center>([\s\S]+?)<\/center>/, 1).map(x => createTree('center', r.inline.atLeast(1).tryParse(x), {}))),
|
||||
inlineCode: () => P.regexp(/`([^´\n]+?)`/, 1).map(x => createLeaf('inlineCode', { code: x })),
|
||||
mathBlock: r => r.startOfLine.then(P.regexp(/\\\[([\s\S]+?)\\\]/, 1).map(x => createLeaf('mathBlock', { formula: x.trim() }))),
|
||||
|
|
|
@ -73,6 +73,12 @@ export function toHtml(tokens: MfmForest | null, mentionedRemoteUsers: IMentione
|
|||
return el;
|
||||
},
|
||||
|
||||
shake(token) {
|
||||
const el = doc.createElement('i');
|
||||
appendChildren(token.children, el);
|
||||
return el;
|
||||
},
|
||||
|
||||
flip(token) {
|
||||
const el = doc.createElement('span');
|
||||
appendChildren(token.children, el);
|
||||
|
|
|
@ -52,6 +52,10 @@ export function toString(tokens: MfmForest | null, opts?: RestoreOptions): strin
|
|||
return `<twitch>${appendChildren(token.children, opts)}</twitch>`;
|
||||
},
|
||||
|
||||
shake(token, opts) {
|
||||
return `<shake>${appendChildren(token.children, opts)}</shake>`;
|
||||
},
|
||||
|
||||
flip(token, opts) {
|
||||
return `<flip>${appendChildren(token.children, opts)}</flip>`;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue