allow incoming ruby tag
This commit is contained in:
parent
b6da190536
commit
a28a61a41d
@ -200,6 +200,21 @@ export class MfmService {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'ruby': {
|
||||
const rtText = node.childNodes
|
||||
.filter((n) => n.nodeName === 'rt')
|
||||
.map((n) => getText(n)).join(' ');
|
||||
const rubyText = node.childNodes
|
||||
.filter((n) => treeAdapter.isTextNode(n))
|
||||
.map((n) => getText(n)).join(' ');
|
||||
if (rubyText && rtText) {
|
||||
text += `$[ruby ${rubyText}|${rtText} ]`;
|
||||
} else {
|
||||
appendChildren(node.childNodes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'p':
|
||||
case 'h2':
|
||||
case 'h3':
|
||||
@ -310,8 +325,14 @@ export class MfmService {
|
||||
const rpEndEl = doc.createElement('rp');
|
||||
rpEndEl.appendChild(doc.createTextNode(')'));
|
||||
|
||||
// Optimization for Latin users
|
||||
if (text.includes('|')) {
|
||||
rubyEl.appendChild(doc.createTextNode(text.split('|')[0]));
|
||||
rtEl.appendChild(doc.createTextNode(text.split('|')[1]));
|
||||
} else {
|
||||
rubyEl.appendChild(doc.createTextNode(text.split(' ')[0]));
|
||||
rtEl.appendChild(doc.createTextNode(text.split(' ')[1]));
|
||||
}
|
||||
rubyEl.appendChild(rpStartEl);
|
||||
rubyEl.appendChild(rtEl);
|
||||
rubyEl.appendChild(rpEndEl);
|
||||
|
@ -289,7 +289,11 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
|
||||
if (!disableNyaize && shouldNyaize) {
|
||||
text = Misskey.nyaize(text);
|
||||
}
|
||||
if (text.includes('|')) {
|
||||
return h('ruby', {}, [text.split('|')[0], h('rt', text.split('|')[1])]);
|
||||
} else {
|
||||
return h('ruby', {}, [text.split(' ')[0], h('rt', text.split(' ')[1])]);
|
||||
}
|
||||
} else {
|
||||
const rt = token.children.at(-1)!;
|
||||
let text = rt.type === 'text' ? rt.props.text : '';
|
||||
|
Loading…
Reference in New Issue
Block a user