Lint
This commit is contained in:
parent
336f890781
commit
409c0f854c
50
src/index.js
50
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 = /^\$\[(?<markup>[\w\d]+)(?:\.(?<options>\S+))? (?<text>.+)\]$/
|
||||
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 = "") => `<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)}]`
|
||||
}
|
||||
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)}]`
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
],
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue