fix link display

This commit is contained in:
FloatingGhost 2022-06-14 17:07:46 +01:00
parent 9f764a4217
commit 38d1074992

View file

@ -7,8 +7,7 @@ function concat (xss) {
return ([]).concat(...xss) return ([]).concat(...xss)
} }
export const MFM_TAGS = ['tada', 'jelly', 'twitch', 'shake', 'spin', 'jump', 'bounce', 'flip', 'x2', 'x3', 'x4', 'font', 'blur', 'rainbow', 'sparkle', 'rotate']; export const MFM_TAGS = ['tada', 'jelly', 'twitch', 'shake', 'spin', 'jump', 'bounce', 'flip', 'x2', 'x3', 'x4', 'font', 'blur', 'rainbow', 'sparkle', 'rotate']
export default defineComponent({ export default defineComponent({
props: { props: {
@ -79,13 +78,13 @@ export default defineComponent({
} }
case 'spin': { case 'spin': {
const direction = const direction =
token.props.args.left ? 'reverse' token.props.args.left ? 'reverse'
: token.props.args.alternate ? 'alternate' : token.props.args.alternate ? 'alternate'
: 'normal' : 'normal'
const anime = const anime =
token.props.args.x ? 'mfm-spinX' token.props.args.x ? 'mfm-spinX'
: token.props.args.y ? 'mfm-spinY' : token.props.args.y ? 'mfm-spinY'
: 'mfm-spin' : 'mfm-spin'
const speed = validTime(token.props.args.speed) || '1.5s' const speed = validTime(token.props.args.speed) || '1.5s'
style = `animation: ${anime} ${speed} linear infinite; animation-direction: ${direction};` style = `animation: ${anime} ${speed} linear infinite; animation-direction: ${direction};`
break break
@ -100,9 +99,9 @@ export default defineComponent({
} }
case 'flip': { case 'flip': {
const transform = const transform =
(token.props.args.h && token.props.args.v) ? 'scale(-1, -1)' (token.props.args.h && token.props.args.v) ? 'scale(-1, -1)'
: token.props.args.v ? 'scaleY(-1)' : token.props.args.v ? 'scaleY(-1)'
: 'scaleX(-1)' : 'scaleX(-1)'
style = `transform: ${transform};` style = `transform: ${transform};`
break break
} }
@ -120,13 +119,13 @@ export default defineComponent({
} }
case 'font': { case 'font': {
const family = const family =
token.props.args.serif ? 'serif' token.props.args.serif ? 'serif'
: token.props.args.monospace ? 'monospace' : token.props.args.monospace ? 'monospace'
: token.props.args.cursive ? 'cursive' : token.props.args.cursive ? 'cursive'
: token.props.args.fantasy ? 'fantasy' : token.props.args.fantasy ? 'fantasy'
: token.props.args.emoji ? 'emoji' : token.props.args.emoji ? 'emoji'
: token.props.args.math ? 'math' : token.props.args.math ? 'math'
: null : null
if (family) style = `font-family: ${family};` if (family) style = `font-family: ${family};`
break break
} }
@ -174,10 +173,11 @@ export default defineComponent({
key: Math.random(), key: Math.random(),
href: token.props.url, href: token.props.url,
rel: 'nofollow noopener' rel: 'nofollow noopener'
})] }, token.props.url)]
} }
case 'link': { case 'link': {
console.log(token.props)
return [h('a', { return [h('a', {
key: Math.random(), key: Math.random(),
href: token.props.url, href: token.props.url,
@ -250,6 +250,21 @@ export default defineComponent({
return token.props.emoji return token.props.emoji
} }
case 'math': {
return [h('pre', {
key: Math.random(),
code: token.props.code
})]
}
case 'mathInline': {
return [h('pre', {
key: Math.random(),
code: token.props.code,
inline: true
})]
}
default: { default: {
console.error('unrecognized ast type:', token.type) console.error('unrecognized ast type:', token.type)