LoginSignup
1
1

More than 5 years have passed since last update.

HomeBrew でインストールした discount で GFM スタイルの `Fenced code blocks` を有効にする

Posted at

概要

Markdown の実装である discountGFM ではおなじみの ``` でコードを囲う書き方をサポートしています。
しかしながら、HomeBrew でインストールした場合はこの機能が有効になっていません。

$ brew install discount
$ echo "\`\`\`ruby\nputs 'hello'\n\`\`\`" | markdown
<p><code>ruby
puts 'hello'
</code></p>

残念なことに執筆時点ではオプションでの指定できません。

$ brew options discount
$

解決策

HomeBrew ではコンパイル時のオプションを渡す方法がないので、以下のように Formula ファイルを書き換えてオプションを追加してやる必要があります。

diff --git Library/Formula/discount.rb Library/Formula/discount.rb
index de15dcd..1d77a15 100644
--- Library/Formula/discount.rb
+++ Library/Formula/discount.rb
@@ -12,6 +12,7 @@ class Discount < Formula
     system "./configure.sh", "--prefix=#{prefix}",
                              "--mandir=#{man}",
                              "--with-dl=Both",
+                             "--with-fenced-code",
                              "--enable-all-features"
     bin.mkpath
     lib.mkpath

これでインストールすると問題なく変換出来ました。

$ brew install discount
$ echo "\`\`\`ruby\nputs 'hello'\n\`\`\`" | markdown
<pre><code class="ruby">puts 'hello'
</code></pre>

補足

オプションを指定出来るようにプルリクエストを作成済なのでそのうち取り込まれるかもしれません。

$ brew options discount
--with-fenced-code
    Enable Pandoc-style fenced code blocks.

$ brew install discount --with-fenced-code

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1