diff options
| author | dakkar <dakkar@thenautilus.net> | 2025-02-07 18:20:36 +0000 |
|---|---|---|
| committer | dakkar <dakkar@thenautilus.net> | 2025-02-07 18:22:45 +0000 |
| commit | d426e2a7ef5fae1f93769d2e53cfef248146f447 (patch) | |
| tree | dd32e61a137076523e108309ffd956c1a3f07a22 /packages/backend/src/core | |
| parent | fix dockerfile (diff) | |
| download | sharkey-d426e2a7ef5fae1f93769d2e53cfef248146f447.tar.gz sharkey-d426e2a7ef5fae1f93769d2e53cfef248146f447.tar.bz2 sharkey-d426e2a7ef5fae1f93769d2e53cfef248146f447.zip | |
fix our ruby/group hack
Diffstat (limited to 'packages/backend/src/core')
| -rw-r--r-- | packages/backend/src/core/MfmService.ts | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/packages/backend/src/core/MfmService.ts b/packages/backend/src/core/MfmService.ts index 2095ebca98..99adad3018 100644 --- a/packages/backend/src/core/MfmService.ts +++ b/packages/backend/src/core/MfmService.ts @@ -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; } |