blog/content/post/2013-06-29-00001582.md

104 lines
6.4 KiB
Markdown
Raw Normal View History

2019-03-31 11:00:21 +00:00
---
title: Github Flavored Markdown を Octopress で使用する
author: kazu634
date: 2013-06-29
url: /2013/06/29/_1796/
geo_latitude:
- 38.306229
geo_longitude:
- 141.022706
geo_public:
- 1
wordtwit_posted_tweets:
- 'a:1:{i:0;i:1823;}'
wordtwit_post_info:
- 'O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:1823;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}'
categories:
- インフラ
---
## Github Flavored Markdown
備忘録として記録しておきます:
1. `Gemfile`に`gem 'redcarpet', '~> 2.1.1'`を追加する
2. `Gemfile`に`gem 'albino', '~> 1.3.3'`を追加する
3. `bundle install`
4. `plugin`ディレクトリに`redcarpet2_markdown.rb`を追加する(<a href="https://raw.github.com/nono/Jekyll-plugins/master/redcarpet2_markdown.rb" onclick="__gaTracker('send', 'event', 'outbound-article', 'https://raw.github.com/nono/Jekyll-plugins/master/redcarpet2_markdown.rb', 'Source Code');">Source Code</a>)
5. `_config.yml`の`markdown: rdiscount`を以下のように修正する<figure class='code'> <figcaption>
<span></span></figcaption>
<div class="highlight">
<table>
<tr>
<td class="gutter">
<pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre>
</td>
<td class='code'>
<pre><code class='diff'>&lt;span class='line'>&lt;span class="gd">-markdown: rdiscount&lt;/span>
&lt;/span>&lt;span class='line'>&lt;span class="gd">-rdiscount:&lt;/span>
&lt;/span>&lt;span class='line'>&lt;span class="gd">- extensions:&lt;/span>
&lt;/span>&lt;span class='line'>&lt;span class="gd">- - autolink&lt;/span>
&lt;/span>&lt;span class='line'>&lt;span class="gd">- - footnotes&lt;/span>
&lt;/span>&lt;span class='line'>&lt;span class="gd">- - smart&lt;/span>
&lt;/span>&lt;span class='line'>&lt;span class="gi">+markdown: redcarpet2&lt;/span>
&lt;/span>&lt;span class='line'>&lt;span class="gi">+redcarpet:&lt;/span>
&lt;/span>&lt;span class='line'>&lt;span class="gi">+ extentions: ["hard_wrap"]&lt;/span>
&lt;/span></code></pre>
</td>
</tr>
</table>
</div></figure>
## Pygment.rbの不具合
Snow Leopardだとなぜか<a href="https://github.com/tmm1/pygments.rb/issues/45" onclick="__gaTracker('send', 'event', 'outbound-article', 'https://github.com/tmm1/pygments.rb/issues/45', 'この問題');">この問題</a>に悩まされたため、この対応を実施しました:
> @mattwildig &#8211; thanks for posting your fix here. I was getting the same with Ruby 1.8, Pygments 0.5.0, and Python 2.6.1. Commenting out the relevant block in mentos.py fixed the issue for me (and now Jekyll works again &#8211; see mojombo/jekyll#1181).
具体的には`pygments.rb/lib/pygments/mentos.py`の<a href="https://github.com/tmm1/pygments.rb/blob/f82642a314bfc80088eea6e81df44b11e8d2193a/lib/pygments/mentos.py#L339-L343" onclick="__gaTracker('send', 'event', 'outbound-article', 'https://github.com/tmm1/pygments.rb/blob/f82642a314bfc80088eea6e81df44b11e8d2193a/lib/pygments/mentos.py#L339-L343', '以下の行');">以下の行</a>をコメントアウトしました:<figure class='code'> <figcaption>
<span></span></figcaption>
<div class="highlight">
<table>
<tr>
<td class="gutter">
<pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre>
</td>
<td class='code'>
<pre><code class='python'>&lt;span class='line'>&lt;span class="k">for&lt;/span> &lt;span class="n">fd&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">maxfd&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;span class='line'> &lt;span class="k">try&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;span class='line'> &lt;span class="n">os&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">close&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">fd&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;span class='line'> &lt;span class="k">except&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;span class='line'> &lt;span class="k">pass&lt;/span>
&lt;/span></code></pre>
</td>
</tr>
</table>
</div></figure>
## 参考URL
* <a href="http://tdksk.github.io/blog/2013/05/06/use-gfm-in-octopress/" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://tdksk.github.io/blog/2013/05/06/use-gfm-in-octopress/', 'Octopress で GitHub Flavored Markdown (GFM) を使う');">Octopress で GitHub Flavored Markdown (GFM) を使う</a>
* <a href="http://yangsu.github.io/blog/2012/10/11/using-octopress-with-github-flavored-markdown-redcarpet/" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://yangsu.github.io/blog/2012/10/11/using-octopress-with-github-flavored-markdown-redcarpet/', 'Using Octopress With Github Flavored Markdown (RedCarpet)');">Using Octopress With Github Flavored Markdown (RedCarpet)</a>
* <a href="http://stackoverflow.com/questions/13464590/github-flavored-markdown-and-pygments-highlighting-in-jekyll" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://stackoverflow.com/questions/13464590/github-flavored-markdown-and-pygments-highlighting-in-jekyll', 'Github flavored Markdown and pygments highlighting in Jekyll');">Github flavored Markdown and pygments highlighting in Jekyll</a>
* <a href="https://github.com/tmm1/pygments.rb/issues/45" onclick="__gaTracker('send', 'event', 'outbound-article', 'https://github.com/tmm1/pygments.rb/issues/45', 'MentosError header errors');">MentosError header errors</a>
* <a href="https://github.com/mojombo/jekyll/issues/1181" onclick="__gaTracker('send', 'event', 'outbound-article', 'https://github.com/mojombo/jekyll/issues/1181', 'Liquid Exception: Failed to get header. in 2013-06-04-welcome-to-jekyll.markdown');">Liquid Exception: Failed to get header. in 2013-06-04-welcome-to-jekyll.markdown</a>