Pandocのインストール方法にCentOSが無かったのですがEPELにパッケージがありました。
とりあえずPandocを試してみたかったので今回はこのパッケージを利用しました。
Pandocのインストール
PandocでMarkdownファイルをHTMLファイルに変換
- # EPELリポジトリを取得
- wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
- # EPELリポジトリをインストール
- rpm -ivh epel-release-6-8.noarch.rpm
- # Pandocパッケージがあることを確認
- yum info pandoc
- # Pandocパッケージをインストール
- yum install pandoc
input.mdの内容
- # Markdownファイルを作成
- vi input.md
- # MarkdownファイルをHTMLファイルに変換
- pandoc input.md -o input.html
input.htmlの内容
- # test
- ## テスト
入力ファイルの文字コードはutf-8で作成しましたが、日本語も表示されていました。
- <h1 id="test">test</h1>
- <h2 id="テスト">テスト</h2>
今回インストールしたPandocは約2年前のバージョン(リリースページ)になるので利用するときは
だいぶ前のバージョンということを考慮しといたほうが良いかもしれないです。
Pandocパッケージ情報
- Name : pandoc
- Arch : x86_64
- Version : 1.9.4.1
- Release : 1.1.el6
- Size : 1.1 M
- Repo : epel
- Summary : Markup conversion tool for markdown
- URL : http://hackage.haskell.org/package/pandoc
- License : GPLv2+
- Description : Pandoc is a Haskell library for converting from one markup format to another,
- : and a command-line tool that uses this library. It can read markdown and
- : (subsets of) reStructuredText, HTML, and LaTeX, and it can write markdown,
- : reStructuredText, HTML, LaTeX, ConTeXt, Docbook, OpenDocument, ODT, RTF,
- : MediaWiki, groff man pages, EPUB, and S5 and Slidy HTML slide shows.