1
0
mirror of https://git.boykissers.com/pawkey/pawkey-sk.git synced 2025-12-20 04:04:16 +00:00

fix our ruby/group hack

This commit is contained in:
dakkar
2025-02-07 18:20:36 +00:00
parent 29b1f61d67
commit d426e2a7ef
2 changed files with 18 additions and 9 deletions

View File

@@ -179,7 +179,8 @@ export class MfmService {
break;
}
case 'ruby': {
// this is here only to catch upstream changes!
case 'ruby--': {
let ruby: [string, string][] = [];
for (const child of node.childNodes) {
if (child.nodeName === 'rp') {
@@ -310,16 +311,24 @@ export class MfmService {
continue;
}
if (child.nodeName === 'rt') {
text += '$[ruby $[group ';
// the only case in which we don't need a `$[group ]`
// is when both sides of the ruby are simple words
const needsGroup = nonRtNodes.length > 1 ||
/\s|\[|\]/.test(getText(nonRtNodes[0])) ||
/\s|\[|\]/.test(getText(child)) ;
text += '$[ruby ';
if (needsGroup) text += '$[group ';
appendChildren(nonRtNodes);
text += '] ';
if (needsGroup) text += ']';
text += ' ';
analyze(child);
text += '] ';
text += ']';
nonRtNodes = [];
continue;
}
nonRtNodes.push(child);
}
appendChildren(nonRtNodes);
}
break;
}