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

Google 翻訳でコードブロックの中身が壊れる #23

Open
dynamis opened this issue Oct 28, 2018 · 3 comments
Open

Google 翻訳でコードブロックの中身が壊れる #23

dynamis opened this issue Oct 28, 2018 · 3 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@dynamis
Copy link
Contributor

dynamis commented Oct 28, 2018

当たり前といえば当たり前なのだが、チュートリアルを Gooogle 翻訳で英語にして読んでいる場合にコードブロックをそのままコピペして実行しようとすると動かないことがある。

全て英語でちゃんと書かれたページを用意できればそれで良いのだけど、何か他に対策がないか。

  • 翻訳対象外とマークする方法がないか
  • lang=en とか付けておけばスルーしたりしないか?
@dynamis
Copy link
Contributor Author

dynamis commented Oct 31, 2018

class="notranslate" を付ければ良いらしい

https://webmasters.googleblog.com/2008/10/helping-you-break-language-barrier.html

ただコードブロックを書く度にこれを付けるのって超面倒で絶対作業抜けが発生する。
サイトのビルド (jekyll や netlify) 側で何とか出来ないか検討したいところ。

@sizuhiko
Copy link
Contributor

sizuhiko commented Nov 1, 2018

現時点のGitHub PagesはJekyll3系なので、以下のように _config.yml に記述すると class を追加できると思います。

https://help.github.com/articles/updating-your-markdown-processor-to-kramdown/

kramdown:
  input: GFM
  syntax_highlighter: rouge
  syntax_highlighter_opts:
    css_class: 'notranslate'

@dynamis dynamis added bug Something isn't working enhancement New feature or request labels Nov 13, 2018
@dynamis
Copy link
Contributor Author

dynamis commented Oct 16, 2019

折角コメント頂いていたのに見逃してましたごめんなさい。 syntax_highlighter_opts とかあったのですね。ただ、GitHub ドキュメントで書かれている kramdown の設定しててもどうも GitHub Pages と挙動違うなと調べた結果、CommonMarkGhPages 使うようになってた https://github.com/github/pages-gem/releases/tag/v172 ためそれに合わせています。そちらで使ってる syntax highight 周りのオプション指定を調べないとですね。

あと、付加する属性としては translate グローバル属性 <p translate="no"> の方良さそうでした。任意属性が付与できないなら class で良いけど。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants