気の向くままに書き綴る

勉強会参加したメモや日々の思ったことのメモ等

GitHubのREADMEをローカルで確認する。octodownをインストール。

 

f:id:koudaiii:20150201192548p:plain


READMEを書くときによく、

GitHub Preview を使って書いていたけど、

  • 微妙にgithubとデザインが違っている
  • ネットが繋がっていないとダメ

と課題があってローカルで確認できるのに良いのないかなぁと思っていた。

上のような課題に対して、
最近では、octodownを使っている。

octodown はローカル上にhtmlを発行して、
ブラウザでREADMEを確認できる。
デザインもGithubそのもので非常に良いです。


ianks/octodown · GitHub

 

環境の前提条件

 brewを最新版にしておく

$ brew doctor
Your system is ready to brew.

 

 

必要なコンポーネントをインストール


$ brew install icu4c cmake pkg-config

octodownインストール

$ gem install octodown

Building native extensions. This could take a while...
Successfully installed nokogumbo-1.2.0
Fetching: crass-1.0.1.gem (100%)
Successfully installed crass-1.0.1
Fetching: sanitize-3.1.0.gem (100%)
Successfully installed sanitize-3.1.0
Fetching: github-markdown-0.6.8.gem (100%)
Building native extensions. This could take a while...
Successfully installed github-markdown-0.6.8
Fetching: gemoji-2.1.0.gem (100%)
Successfully installed gemoji-2.1.0
Fetching: yajl-ruby-1.1.0.gem (100%)
Building native extensions. This could take a while...
Successfully installed yajl-ruby-1.1.0
Fetching: pygments.rb-0.6.0.gem (100%)
Successfully installed pygments.rb-0.6.0
Fetching: octodown-1.0.4.gem (100%)
Successfully installed octodown-1.0.4
8 gems installed 

 確認


$ gem list octodown 
*** LOCAL GEMS ***

octodown (1.0.4)

実行


$ octodown README.md

f:id:koudaiii:20150201192225g:plain

Tips

gem install した際に、OS XのVersionアップに影響して失敗してしまうことがあるみたい。
今回は、$ xcode-select --install 実行している。


$ gem install octodown
Fetching: posix-spawn-0.3.9.gem (100%)
Building native extensions. This could take a while...
Successfully installed posix-spawn-0.3.9
Fetching: github-markup-1.3.1.gem (100%)
Successfully installed github-markup-1.3.1
Fetching: rugged-0.22.0b5.gem (100%)
Building native extensions. This could take a while...
Successfully installed rugged-0.22.0b5
Fetching: escape_utils-1.0.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed escape_utils-1.0.1
Fetching: charlock_holmes-0.7.3.gem (100%)
Building native extensions. This could take a while...
Successfully installed charlock_holmes-0.7.3
Fetching: github-linguist-4.2.6.gem (100%)
Successfully installed github-linguist-4.2.6
Fetching: html-pipeline-1.11.0.gem (100%)
-------------------------------------------------
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
-------------------------------------------------
Successfully installed html-pipeline-1.11.0
Fetching: nokogumbo-1.2.0.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing octodown:
ERROR: Failed to build gem native extension.

/Users/cs006061/.rbenv/versions/2.1.5/bin/ruby extconf.rb
checking for xmlNewDoc() in -lxml2... yes
checking for nokogiri.h in /Users/cs006061/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.5/ext/nokogiri... no
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
-----
The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.

To install Command Line Tools, try running `xcode-select --install` on
terminal and follow the instructions. If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/cs006061/.rbenv/versions/2.1.5/bin/ruby
--with-xml2lib
--without-xml2lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build

extconf failed, exit code 1

Gem files will remain installed in /Users/cs006061/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/nokogumbo-1.2.0 for inspection.
Results logged to /Users/cs006061/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/nokogumbo-1.2.0/gem_make.out

 


ありゃ、失敗した。エラーメッセージに下記書いてあるので実行。

 

To install Command Line Tools, try running `xcode-select --install` on
terminal and follow the instructions. If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.

 

 xcode-select --install


$ xcode-select --install
xcode-select: note: install requested for command line developer tools

 nokogiriも念のため確認

$ gem list nokogiri

*** LOCAL GEMS ***

nokogiri (1.6.5, 1.6.4.1)


 もう一回gem install octodownで入りました。