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

Apply a class to <em>'s containing Japanese characters #94

Merged
merged 4 commits into from Feb 7, 2019

Conversation

smikitky
Copy link
Member

@smikitky smikitky commented Feb 7, 2019

This fixes #22 .

  • Added a Gatsby custom plugin that iterates over markdown AST and add em-ja class to <em>'s that contain any Japanese character.
  • Added a CSS rule to render .em-ja with bold instead of italic.

環境によって日本語で em が正しくレンダリングされない問題を修正します。em で強調されている文字列に日本語文字が含まれている場合(例: *あああ*)、問答無用で太字にします。

もし yarn dev で太字が反映されない場合は yarn reset でキャッシュを削除してみてください。

const visit = require('unist-util-visit');

const hasJapanese = str => {
return /[\u30a0-\u30ff\u3040-\u309f\u3005-\u3006\u30e0-\u9fcf。、]/.test(str);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[imo]
hasJapanese から推測できますが、一応 regex の範囲についてコメントしておいても良いかもしれません。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

念のため確認してたらCJK統合漢字のコードポイント間違ってました…(コピペ元から間違ってました)

Copy link
Member

@potato4d potato4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

screen shot 2019-02-08 at 1 25 42

動作見ました。良さそうです!
一点、 imo を書いておいたので、もしよろしければ検討いただけるとー。

@smikitky
Copy link
Member Author

smikitky commented Feb 7, 2019

@potato4d コメントを加えてみましたが、ああいうことでよかったでしょうか

Copy link
Member

@koba04 koba04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

確認しました。問題ないと思います 👍

@smikitky smikitky merged commit 9dffa43 into master Feb 7, 2019
@smikitky smikitky deleted the fix-emphasis branch February 7, 2019 16:44
@potato4d
Copy link
Member

potato4d commented Feb 7, 2019

@smikitky 良いと思います〜!

@smikitky smikitky added the workflow Working environment improvements including linting and CSS styles label Feb 13, 2019
@smikitky smikitky mentioned this pull request Dec 1, 2021
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workflow Working environment improvements including linting and CSS styles
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Font issue related to <em>
3 participants