Jekyll
Total: 12062, Today: 2, Yesterday: 4
Posted by aterai at
Last-modified:
Summary
Windows + Cygwin64 + ruby 2.0.0の環境で、JekyllをインストールしMarkdown記法のテキストから静的サイトを生成します。
インストール
setup-x86_64.exeから、gcc-core、make、ruby、rubygems、ruby-devel、libffi-devel、openssh、openssl、gitをインストール~/.gemrcを作成install: --no-document update: --no-document
gemでインストールgem install jekyll
tr: invalid byte sequence in UTF-8 (ArgumentError)とエラーになる場合- Cygwin - Ruby-1.9.3p327 - win32/registry - PIBを参考にして、
C:/cygwin64/usr/share/ruby/2.0.0/win32/registry.rbを修正# # Error # class Error < ::StandardError module Kernel32 extend Fiddle::Importer dlload "kernel32.dll" end # FormatMessageA = Kernel32.extern "int FormatMessageA(int, void *, int, int, void *, int, void *)", :stdcall # def initialize(code) # @code = code # msg = "\0".force_encoding(Encoding::ASCII_8BIT) * 1024 # len = FormatMessageA.call(0x1200, 0, code, 0, msg, 1024, 0) # msg = msg[0, len].force_encoding(Encoding.find(Encoding.locale_charmap)) # super msg.tr("\r", '').chomp # end FormatMessageW = Kernel32.extern "int FormatMessageW(int, void *, int, int, void *, int, void *)", :stdcall def initialize(code) @code = code msg = "\0\0".force_encoding(Encoding::UTF_16LE) * 1024 len = FormatMessageW.call(0x1200, 0, code, 0, msg, msg.size, 0) msg = msg[0, len].encode(Encoding.find(Encoding.locale_charmap)) super msg.tr("\r".encode(msg.encoding), '').chomp end attr_reader :code end
- Cygwin - Ruby-1.9.3p327 - win32/registry - PIBを参考にして、
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../x86_64-pc-cygwin/bin/ld: -lcrypt が見つかりませんとエラーになる場合libcrypt-develをsetup-x86_64.exeからインストールしてgem install jekyllを再実行
Makefile:232: recipe for target 'ffi_c.so' failedとエラーになる場合- Problems compiling ffi 1.9.0 on cygwin 64bit ・ Issue #284 ・ ffi/ffi (via: make fails on Cygwin64bit ・ Issue #317 ・ ffi/ffi)などを参考に、
cygwin32-libffi、libffi-devel、pkg-configなどをsetup-x86_64.exeからインストールしてgem install jekyllを再実行export PKG_CONFIG_PATH="/lib/pkgconfig" gem install jekyll
- Problems compiling ffi 1.9.0 on cygwin 64bit ・ Issue #284 ・ ffi/ffi (via: make fails on Cygwin64bit ・ Issue #317 ・ ffi/ffi)などを参考に、
-lgmp が見つかりませんとエラーになる場合libgmp-develをsetup-x86_64.exeからインストールgcc -shared -o stemmer.so porter.o porter_wrap.o -L. -L/usr/lib -L. -fstack-protector -Wl,--export-all-symbols -Wl,--enable-auto-image-base,--enable-auto-import -lruby220 -lpthread -lgmp -ldl -lcrypt /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: -lgmp が見つかりません collect2: エラー: ld はステータス 1 で終了しました Makefile:254: ターゲット 'stemmer.so' のレシピで失敗しました make: *** [stemmer.so] エラー 1
実行
jekyll new my-awesome-siteでmy-awesome-siteディレクトリを作成/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in 'require': cannot load such file -- bigdecimal (LoadError)とエラーになる場合gem install bigdecimalでbigdecimalをインストール
cd my-awesome-site && bundle exec jekyll buildでビルドLoadError: cannot load such file -- bigdecimalとエラーになる場合./my-awesome-site/Gemfileファイルにgem 'bigdecimal'を一行追加
LoadError: cannot load such file -- jsonとエラーになる場合./my-awesome-site/Gemfileファイルにgem 'json'を一行追加
Jekyll で google-code-prettify
- 参考: fnordig.de
パーサーをkramdownにして、行頭タブ(4スペース)ブロックの直後に{:class="prettyprint"}、または{:.prettyprint}を追加
def parse_pre(lines)
[%Q|#{lines.map {|line| "\t".concat(line) }.join("\n")}|, %Q|{:class="prettyprint"}|]
end
### サンプルコード
trayIcon.displayMessage("caption", "text", TrayIcon.MessageType.ERROR);
{:class="prettyprint"}
結果
<h3 id="section">サンプルコード</h3>
<pre class="prettyprint"><code>trayIcon.displayMessage("caption", "text", TrayIcon.MessageType.ERROR);
</code></pre>
default.htmlにprettify.js, prettify.cssを追加
<link href="{{ ASSET_PATH }}/css/prettify.css" type="text/css" rel="stylesheet" />
</head>
<body onload="prettyPrint()">
...
<script src="{{ ASSET_PATH }}/js/prettify.js"></script>
</body>
redcarpet
markdownのパーサーをredcarpetに変更
# _config.yml markdown: redcarpet redcarpet: renderer: Redcarpet::Render::XHTML extensions: ["xhtml", "fenced_code_blocks", "strikethrough", "no_intra_emphasis", "lax_spacing"]
no_intra_emphasis<pre><code>の中でも、アンダーライン(例:InputMap im = combobox.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);)が、<em>...</em>に変換されるので、no_intra_emphasisで回避