2014年9月23日火曜日

CentOS6 に Pandoc を yum でセットアップする

CentOS6にPandocをセットアップしてみました。

Pandocのインストール方法にCentOSが無かったのですがEPELにパッケージがありました。

とりあえずPandocを試してみたかったので今回はこのパッケージを利用しました。

Pandocのインストール
  1. # EPELリポジトリを取得
  2. wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
  3. # EPELリポジトリをインストール
  4. rpm -ivh epel-release-6-8.noarch.rpm
  5. # Pandocパッケージがあることを確認
  6. yum info pandoc
  7. # Pandocパッケージをインストール
  8. yum install pandoc
PandocでMarkdownファイルをHTMLファイルに変換
  1. # Markdownファイルを作成
  2. vi input.md
  3. # MarkdownファイルをHTMLファイルに変換
  4. pandoc input.md -o input.html
input.mdの内容
  1. # test
  2.  
  3. ## テスト
input.htmlの内容
  1. <h1 id="test">test</h1>
  2. <h2 id="テスト">テスト</h2>
入力ファイルの文字コードはutf-8で作成しましたが、日本語も表示されていました。
今回インストールしたPandocは約2年前のバージョン(リリースページ)になるので利用するときは
だいぶ前のバージョンということを考慮しといたほうが良いかもしれないです。

Pandocパッケージ情報
  1. Name : pandoc
  2. Arch : x86_64
  3. Version : 1.9.4.1
  4. Release : 1.1.el6
  5. Size : 1.1 M
  6. Repo : epel
  7. Summary : Markup conversion tool for markdown
  8. URL : http://hackage.haskell.org/package/pandoc
  9. License : GPLv2+
  10. Description : Pandoc is a Haskell library for converting from one markup format to another,
  11. : and a command-line tool that uses this library. It can read markdown and
  12. : (subsets of) reStructuredText, HTML, and LaTeX, and it can write markdown,
  13. : reStructuredText, HTML, LaTeX, ConTeXt, Docbook, OpenDocument, ODT, RTF,
  14. : MediaWiki, groff man pages, EPUB, and S5 and Slidy HTML slide shows.