Giter VIP home page Giter VIP logo

aozora-proc's Introduction

aozora-proc.el … 青空文庫プロセッサ

aozora-proc.el について

青空文庫の文法チェッカ・HTML5・LaTeX・IDMLへの出力を行うツールです。

本ツールは、以下の特徴があります。

  • 青空文庫の注記を解析表現文法で解析し、中間データへ変換します。その ため、パーザ部分は実質的にプログラムコードがなく、簡潔に表記されま す。
  • 中間データからは、HTML5(縦書き・横書き), LaTeX(縦書き・横書き), その他、プラグインを作成すれば、様々なマークアップ言語へ変換できます。
  • UCS漢字とアクセント付き欧文のUCSに対応しています。現状では青空文庫 での利用が確認されている非JIS X 0208漢字8,000字程度が利用できます。
  • org-mode 等、既存のアウトラインプロセッサへの組込みが可能になるよう に、行単位処理を行うAPIを提供しています。
  • シェルスクリプトからのバッチ処理で、複数の作品を一括変換できます。

本プログラムは出力フォーマットによっては青空文庫の注記の一部しか対応 していませんが、プログラム末尾のデータ出力設定部分を適当に拡張・変更 することで、自由に拡張・カスタマイズ可能です。

使い方:

前準備

  1. Emacs (23.2 以降。ucs-normalize.el が必要なため) と、peg.el (http://emacswiki.org/emacs/peg.el) を用意します。peg.elは、 load-pathに含まれるディレクトリ(/usr/local/share/emacs/site-lispなど) にインストールします。
  2. 《オプショナル》 漢字データベースのサイトから、外字データファイル aozora_gaiji_chuki.txt (http://kanji-database.sourceforge.net/aozora/gaiji.html) をダウン ロードし、適当な場所に入れます。

コマンドラインでの使い方

コマンドラインから、 `emacs –script’ で起動します。

  1. 注記の検証を行う場合:
    % emacs --script aozora-proc.el file.txt
        

    としてください。注記に間違いがある場合はその行を表示します。(実際 にはその前後の行で間違っている場合もあります。)

  2. HTMLやLaTeXへ変換する場合:

    -f オプションでフォーマットを指定します。

    % emacs --script aozora-proc.el -f html-v file1.txt file2.txt ...
        

    ここで変換先フォーマット (-f) は `html-h’, `uptex-h’ (横書き), `html-v’, `uptex-v’, ‘idml’ (縦書き) が選択できます。

    縦書きHTMLは、WebKit Nightly Builds 等のブラウザで確認できます。 IDMLで指定して出力されるxmlファイルは、IDMLのストーリーファイルと して利用できます。

    処理途中で文法エラーが見付かった場合は、エラー表示をした後、そこま での変換処理をファイルに保存します。

    upTeX (uplatex) 版 はまだ開発途上です。またマクロの衝突の問題によ り、いくつかの修飾が重なった場合は手で修正しなければならない場合 があります。

  3. 他の詳細なオプションについては
    % emacs --script aozora-proc.el -h
        

    で確認してください。

Emacs での使い方

  1. M-x load-library aozora-proc 等で本ライブラリを読み込みます。
  2. 変換したいファイル(例:sample.txt)を開きます。
  3. M-x aozora-proc-select-method で、変換フォーマットを選択します。 または、=.emacs.d/init.el= に、以下のように変換フォーマットを設定 します。
    (setq aozora-proc-method 'html-v)
        
  4. ファイルを検証したい場合は、M-x aozora-proc-parse とします。文法エ ラーがある場合はその箇所で停止します。
  5. HTML/TeX に変換する場合は、 M-x aozora-proc-markup とします。
  6. バッファ全体に対して変換する場合は、M-x aozora-proc-buffer を、ファ イルに対して処理をしたい場合は、M-x aozora-proc-file を実行します。
  7. org-mode で利用する場合は、以下のような設定を init.el に書いて おきます。
    (require 'org)
    (require 'aozora-proc.el nil t)
    (when (functionp 'aozora-proc-lines)
      (add-hook 'org-export-latex-final-hook
                (lambda () (aozora-proc-lines-buffer 'uptex-h)))
      (add-hook 'org-export-html-final-hook
                (lambda () (aozora-proc-lines-buffer 'html-h))))
        

注意

本プログラムを使うことによって生じるいかなる損失・損害についても作者 は責任を負いません。

本プログラムはまだコンセプトベースのα版です。要望があれば徐々に改良 していきます。upTeX出力はルビやセクション、その他の修飾が重複するとマ クロが衝突してうまくコンパイルできない場合がありますので、その場合は 手で修正する必要があります。

IDML出力をInDesignで読みこませるには、Story要素のSelf属性の設定および IDMLアーカイブへの組み込みを別途行う必要があります。

ライセンス

  • aozora-proc.el … GPL (文法部分はのぞく)
  • grammar.txt … BSD

aozora-proc's People

Contributors

kawabata avatar tarui avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.