markdownをpandocを使ってHTMLに変換する
markdownをpandoc
を使ってHTMLに変換しましたので備忘録です。
pandocをインストール
$ brew install pandoc
CSSを指定してHTMLに変換する
使うCSS
GithubなHTMLへ変換する為のCSSが公開されていますので、これを使います。
https://gist.github.com/andyferra/2554919
Defaultのディレクトリに配置する
Defaultディレクトリを確認します。
$ pandoc --version pandoc 1.17.2 Compiled with texmath 0.8.6.4, highlighting-kate 0.6.2.1. Syntax highlighting is supported for the following languages: abc, actionscript, ada, agda, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d, diff, djangotemplate, dockerfile, dot, doxygen, doxygenlua, dtd, eiffel, elixir, email, erlang, fasm, fortran, fsharp, gcc, glsl, gnuassembler, go, hamlet, haskell, haxe, html, idris, ini, isocpp, java, javadoc, javascript, json, jsp, julia, kotlin, latex, lex, lilypond, literatecurry, literatehaskell, llvm, lua, m4, makefile, mandoc, markdown, mathematica, matlab, maxima, mediawiki, metafont, mips, modelines, modula2, modula3, monobasic, nasm, noweb, objectivec, objectivecpp, ocaml, octave, opencl, pascal, perl, php, pike, postscript, prolog, pure, python, r, relaxng, relaxngcompact, rest, rhtml, roff, ruby, rust, scala, scheme, sci, sed, sgml, sql, sqlmysql, sqlpostgresql, tcl, tcsh, texinfo, verilog, vhdl, xml, xorg, xslt, xul, yacc, yaml, zsh Default user data directory: /Users/hirokiyoshino/.pandoc Copyright (C) 2006-2016 John MacFarlane Web: http://pandoc.org This is free software; see the source for copying conditions. There is no warranty, not even for merchantability or fitness for a particular purpose.
Default user data directory: /Users/hirokiyoshino/.pandoc
とのことなので、このディレクトリを作成
$ mkdir ~/.pandoc
この中に、cssをいれます。
変換
$ pandoc -s input.md -c ~/.pandoc/github.css -o output.html
うまくいきました。
以下のサイトを参考にさせてもらいました。