Skip to content

tikeda/md2inao.pl

 
 

Repository files navigation

Markdown to Inao-Format

Build Status

Build Status

Description

Markdown で書かれたテキストを「inaoフォーマット」に変換します。

markdown2inao.pl 改め md2inao.pl のこれまでについては https://gist.github.com/inao/baea09bc6fc53551886b を見て下さい。

How to use

% cpanm Carton
% carton
% carton exec perl bin/md2inao.pl your_markdown.md > path/to/output.txt

出力見本

PDFにすると、以下のような仕上がりになります。

書籍版

https://docs.google.com/open?id=0BzbGMS73rIkDUXpyUVlrSUxURXlmMXhQRV9Ua2JCUQ

WEB+DB PRESS版

https://docs.google.com/open?id=0BzbGMS73rIkDZjdCTnBkMDFUaGF2UDJIdTNfaVJUUQ

How to test

% 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 の文法に注意 (末尾のカンマ、" のエスケープなど)

before_filter

  • Markdown parse の前に置換
  • Markdown のテキストを置換したい時は こちら
  • HTML を置換したい時もこちら
  • 値の <, > はエスケープされてから Markdown parser に渡されます。その後 after_filter で復元されます。(要するに書いたとおりに出力される。HTMLとして処理されることは期待できない、ということ)

after_filter

  • InDesign への変換が終わった後に置換
  • InDesign になったテキストを置換したい時はこちら
  • md 中の <span class="symbol">…</span> は after_filter 前に ◆…◆ になります

Authors

捕捉

  • gist から普通のレポジトリにする方法わかんなくて新規に切っちゃいました。すみません (@naoya)

LICENSE

  • Same as Perl

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

IRC

  • #md2inao@freenode

About

Convert markdown to inao-format for WEB+DB PRESS

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Perl 100.0%