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