Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): Let MfmService.fromHtml() accept <ruby> tags #15117

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

dahlia
Copy link

@dahlia dahlia commented Dec 10, 2024

What

This fix makes MfmService.fromHtml() method accept <ruby> tags and translate it to MFM's ruby characters syntax ($[ruby ...]).

このパッチはMfmService.fromHtml()メソッドが<ruby>タグをMFMの読み仮名(ルビ)文法に翻訳する様に修正します。

Why

Currently, Misskey can display ruby characters via MFM for posts received from other Misskey (and Forkeys) servers, but is unable to display them properly from other software, even if the <ruby> tag is present in the content property. This fix should allow for better interoperability.

現在、MisskeyはMisskey系のサーバーから受け取った投稿の場合、MFMを通じてルビ文字(読み仮名)の表示が出来ますが、それ以外のソフトウェアからはcontentプロパティ内に<ruby>タグが入っていても正しく表示されません。この修正により、より相互運用性が改善されます。

Additional info (optional)

Because HTML's <ruby> tag is much more expressive than MFM's yomigana (ruby character) syntax, it falls back to plain text rendering as before if it goes beyond what MFM can represent (for example, if it contains spaces).

MFMの読み仮名(ルビ)の文法が表現できる範囲よりも、HTMLの<ruby>タグが表現できる範囲がはるかに広いため、MFMで表現できる範囲を超えた場合(例えば、空白を含む場合)、従来通りプレーンテキストレンダリングにフォールバックします。

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Add story of storybook
  • (If needed) Update CHANGELOG.md
  • (If possible) Add tests

@github-actions github-actions bot added packages/backend Server side specific issue/PR packages/backend:test labels Dec 10, 2024
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 39.97%. Comparing base (e8bf628) to head (a74cc14).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #15117      +/-   ##
===========================================
+ Coverage    39.96%   39.97%   +0.01%     
===========================================
  Files         1563     1563              
  Lines       197752   197785      +33     
  Branches      3634     3644      +10     
===========================================
+ Hits         79031    79069      +38     
+ Misses      118116   118111       -5     
  Partials       605      605              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Dec 10, 2024

このPRによるapi.jsonの差分
差分はありません。
Get diff files from Workflow Page

@syobocat
Copy link

関連: #12382

packages/backend/src/core/MfmService.ts Outdated Show resolved Hide resolved
packages/backend/src/core/MfmService.ts Outdated Show resolved Hide resolved
packages/backend/src/core/MfmService.ts Outdated Show resolved Hide resolved
packages/backend/test/unit/MfmService.ts Outdated Show resolved Hide resolved
packages/backend/test/unit/MfmService.ts Outdated Show resolved Hide resolved
packages/backend/test/unit/MfmService.ts Outdated Show resolved Hide resolved
packages/backend/src/core/MfmService.ts Outdated Show resolved Hide resolved
packages/backend/src/core/MfmService.ts Outdated Show resolved Hide resolved
This fix makes `MfmService.fromHtml()` method accept `<ruby>` tags
and translate it to MFM's ruby characters syntax (`$[ruby ...]`).

このパッチは`MfmService.fromHtml()`メソッドが`<ruby>`タグをMFMの
読み仮名(ルビ)文法に翻訳する様に修正します。
@dahlia dahlia force-pushed the mfm-from-html-ruby branch from aa1de2c to a74cc14 Compare December 11, 2024 02:34
@dahlia
Copy link
Author

dahlia commented Dec 11, 2024

I've addressed all of the things that @tesaguri pointed out!

@dahlia
Copy link
Author

dahlia commented Dec 16, 2024

Can someone review this for me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages/backend:test packages/backend Server side specific issue/PR
Projects
Development

Successfully merging this pull request may close these issues.

3 participants