Markdown で書かれたテキストを「inaoフォーマット」に変換します。
- bin/md2inao.pl : CUIコマンド版
- http://md2inao.bloghackers.net/ : Web版
markdown2inao.pl 改め md2inao.pl のこれまでについては https://gist.github.com/inao/baea09bc6fc53551886b を見て下さい。
% cpanm Carton
% carton
% carton exec perl bin/md2inao.pl your_markdown.md > path/to/output.txt
PDFにすると、以下のような仕上がりになります。
https://docs.google.com/open?id=0BzbGMS73rIkDUXpyUVlrSUxURXlmMXhQRV9Ua2JCUQ
https://docs.google.com/open?id=0BzbGMS73rIkDZjdCTnBkMDFUaGF2UDJIdTNfaVJUUQ
% carton exec -Ilib -- prove
{
"before_filter": {
"<kbd>F10</kbd>" : "<cFont:Key Snd Mother>*<cFont:>",
"<kbd>F11</kbd>" : "<cFont:Key Snd Mother>+<cFont:>",
"<kbd>F12</kbd>" : "<cFont:Key Snd Mother>,<cFont:>",
"<kbd>F1</kbd>" : "<cFont:Key Snd Mother>!<cFont:>",
"<kbd>F2</kbd>" : "<cFont:Key Snd Mother>\"<cFont:>",
"<kbd>End</kbd>" : "<cFont:Key Snd Mother>n<cFont:>"
},
"after_filter": {
"★" : "<CharStyle:赤字>★<CharStyle:>",
"◆→◆" : "<cTypeface:R-KL><cFont:A-OTF リュウミン Pr5><27A1><cTypeface:><cFont:>",
"◆←◆" : "<cTypeface:R-KL><cFont:A-OTF リュウミン Pr5><2B05><cTypeface:><cFont:>",
"◆↑◆" : "<cTypeface:R-KL><cFont:A-OTF リュウミン Pr5><2B06><cTypeface:><cFont:>",
"◆↓◆" : "<cTypeface:R-KL><cFont:A-OTF リュウミン Pr5><2B07><cTypeface:><cFont:>",
"◆←→◆" : "<21D4>",
"◆>=◆" : "<2267>",
"◆=>◆" : "<2266>",
"◆WDB◆" : "<cstyle:ストッパ>#<cstyle:>"
}
}
- InDesign 出力時は config/id_filter.json に書いた設定通りに出力を置換できます
- キーには正規表現が使えます
- JSON の文法に注意 (末尾のカンマ、" のエスケープなど)
- Markdown parse の前に置換
- Markdown のテキストを置換したい時は こちら
- HTML を置換したい時もこちら
- 値の <, > はエスケープされてから Markdown parser に渡されます。その後 after_filter で復元されます。(要するに書いたとおりに出力される。HTMLとして処理されることは期待できない、ということ)
- InDesign への変換が終わった後に置換
- InDesign になったテキストを置換したい時はこちら
- md 中の
<span class="symbol">…</span>
は after_filter 前に◆…◆
になります
- @typester : Original version: https://gist.github.com/typester/380428
- @inao : Current product owner & maintainer
- @naoya : Refactoring, Add some tests, Web version
- @hsbt
- @hokaccha
- @suzuki
- gist から普通のレポジトリにする方法わかんなくて新規に切っちゃいました。すみません (@naoya)
- Same as Perl
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
- #md2inao@freenode