This commit is contained in:
Sol Fisher Romanoff 2022-07-08 13:03:03 +03:00
parent 336f890781
commit 409c0f854c
Signed by: nbsp
GPG Key ID: 9D3F2B64F2341B62
1 changed files with 23 additions and 27 deletions

View File

@ -14,7 +14,7 @@ export default {
markup: match.groups.markup,
options: match.groups.options,
text: match.groups.text,
tokens: []
tokens: [],
}
this.lexer.inline(token.text, token.tokens)
return token
@ -28,27 +28,23 @@ export default {
return i
}, {})
}
const el = (mfmClass, mfmStyle = "") => `<span style="display: inline-block;${mfmStyle}" class="${mfmClass}">${this.parser.parseInline(token.tokens)}</span>`
const el = (mfmClass, mfmStyle = '') => `<span style="display: inline-block;${mfmStyle}" class="${mfmClass}">${this.parser.parseInline(token.tokens)}</span>`
switch (token.markup) {
case 'x2': {
return el('x2')
break
}
case 'twitch': {
const speed = options.speed || '0.5s'
return el('twitch', ` animation: mfm-twitch ${speed} ease infinite;`)
break
}
case 'sparkle': {
return el('sparkle')
break
}
case 'spin': {
const direction = options.left ? 'reverse' : options.alternate ? 'alternate' : 'normal'
const anime = options.x ? 'mfm-spinX' : options.y ? 'mfm-spinY' : 'mfm-spin'
const speed = options.speed || '1.5s'
return el('spin', ` animation: ${anime} ${speed} linear infinite; animation-direction: ${direction};`)
break
}
default: {
return `$[${token.markup} ${this.parser.parseInline(token.tokens)}]`
@ -56,5 +52,5 @@ export default {
}
},
},
]
],
}