diff --git a/src/index.js b/src/index.js index 045a56c..b80f932 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ export default { { name: 'mfm', level: 'inline', - start(src) { return src.match(/\$\[/)?.index }, + start (src) { return src.match(/\$\[/)?.index }, tokenizer (src, tokens) { const rule = /^\$\[(?[\w\d]+)(?:\.(?\S+))? (?.+)\]$/ const match = rule.exec(src) @@ -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,33 +28,29 @@ export default { return i }, {}) } - const el = (mfmClass, mfmStyle = "") => `${this.parser.parseInline(token.tokens)}` + const el = (mfmClass, mfmStyle = '') => `${this.parser.parseInline(token.tokens)}` 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)}]` - } + case 'x2': { + return el('x2') + } + case 'twitch': { + const speed = options.speed || '0.5s' + return el('twitch', ` animation: mfm-twitch ${speed} ease infinite;`) + } + case 'sparkle': { + return el('sparkle') + } + 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};`) + } + default: { + return `$[${token.markup} ${this.parser.parseInline(token.tokens)}]` + } } }, }, - ] + ], }