diff --git a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts index f55abfe599..2037730eae 100644 --- a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts +++ b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts @@ -60,7 +60,21 @@ export default function(props: { const res: (VNode | string)[] = []; for (const t of text.split('\n')) { res.push(h('br')); - res.push(t); + t.replace(/(.+?)(.+?)<\/rt><\/ruby>/g, '\n$1$2\n') + .replace(/《《(.+?)》》/g, (match, c1) => c1.replace(/(.)/g, '\n$1\n')) + .replace(/[\||](.+?)《(.+?)》/g, '\n$1$2\n') + .replace(/([一-龠]+)《(.+?)》/g, '\n$1$2\n') + .replace(/[\||]《(.+?)》/g, '《$1》') + .split('\n') + .forEach( t2 => { + const match = t2.match(/(.+?)(.+?)<\/rt><\/ruby>/); + if (match !== null && match.length > 2) { + const rubyAlign = match[1].length < match[2].length ? 'ruby-align:center' : 'ruby-align:space-around'; + res.push(h('ruby', { style: rubyAlign }, [match[1], h('rt', match[2])])); + } else if (t2 !== '') { + res.push(t2); + } + }); } res.shift(); return res;