Skip to content

Instantly share code, notes, and snippets.

@yhara
Last active July 25, 2017 07:54
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yhara/6919425 to your computer and use it in GitHub Desktop.
Save yhara/6919425 to your computer and use it in GitHub Desktop.

redcaretとgithub-markdownの違い

  • 両者のソースは割りと似ている(github-markdownがredcarpetを元にしたのか、あるいは両者のもとになったC実装があるとかかな)

オプションについて

github-markdownは、redcapetの提供するオプションの一部をデフォルトで有効化します。 (ちなみに有効化するオプションを選ぶAPIはない模様。用途を考えるとそれで正しいが)

★がついているのが有効化されるもの。gfmモード(.render_gfmメソッド)の場合のみ、★★も有効化される。

  • ★no_intra_emphasis: foo_bar_bazをemタグにしない。

  • ★tables: PHP-Markdownスタイルの表を有効化。

  • ★fenced_code_blocks: 「~~~」または「```」によるコードブロック。

  • ★autolink: http, https, ftp等の自動リンク。

  • disable_indented_code_blocks: 普通のスペースによるコードブロックを無効化。

  • ★strikethrough: 「~~」によるdelタグの生成。

  • ★lax_spacing: 生HTMLの前後に空行を入れなくて良い?

  • ★★space_after_headers: 「#」のあとに空白を必要とするか。

  • superscript: 「2^n」とか「2^(nd)」みたいなのをsupにするか。

  • underline: _foo_をiタグでなくuタグにする?

  • highlight: 「==」でmarkタグを生成?

  • quote: 「"」でqタグを生成

  • footnotes: 「[^1]」のような記法で注釈を付けられるようにする

  • ★★hard_wrap: 改行を
    にする

  • ...

じゃあredcarpetで上のオプションを有効にすればいいの?

と思ったんだけど、なぜかredcarpetにはfenced code block(```)内に#から始まる行があるとそれがh1になってしまうという謎挙動があり、Github互換のmarkdownがほしい場合はgithub-markdownを使った方が良さげ (単にredcarpet-3.0.0のバグかも知れないけど)。

(2014/02/19追記:これはtdiary-style-gfm側のバグでした。濡れ衣すいません。)

github-markdownが提供しない機能

GFM公式を見るといろいろな機能があるけど、以下の機能はgithub-markdown gemには入ってない模様。

  • Task Lists ([x]とかでチェックボックスを生成する機能)
  • mentions (@foo @yhara)
  • Emoji (:foo: 🍣)
  • refs (tdiary/tdiary-core#12等。これはgistでも使えない)
  • syntax highlighting
    • 別途pygments.rb等を併用する必要がある。例:
GitHub::Markdown.to_html(src, :gfm){|code, lang|
  Pygments.highlight(code, :lexer => lang)
}
@yhara
Copy link
Author

yhara commented Oct 10, 2013

そうか、コメントでは 🍣 が使えるけどgist本文では使えないのか…。

@yhara とかもそうなんですね。mojombo/github-flavored-markdown#1 みたいのは(gistの)コメントでも使えないのか。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment