An assortment of things I needed to make a Japanese PDF document with asciidoctor.
Add this line to your application's Gemfile:
gem 'asciidoctor-nabetani'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install asciidoctor-nabetani
Create PDF from AsciiDoc file with this library like following:
$ asciidoctor-pdf -r asciidoctor/nabetani foobar.adoc -o foobar.pdf
Bug reports and pull requests are welcome on GitHub at https://github.com/nabetani/asciidoctor-nabetani.
This project is inspired by asciidoctor-pdf-linewrap-ja
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Asciidoctor::Nabetani project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
突然日本語ですいません。
AsciiDoctor で PDF を作るときに困っていたことをなんとかしたライブラリ。
prawn の禁則処理を本ライブラリの処理で差し替えることで、禁則処理を改善する。
AsciiDoc のクロスリファレンスで
従来は
形式名 | PDF上の出力例 |
---|---|
full | Section 2.1, “セクション名” |
short | Section 2.1 |
basic | セクション名 |
の三択だった。 |
これを
:xrefstyle: custom
:xrefcustomformat: [$SECT_NUMS$]. [$TITLE$]
などと指定することで、PDF上で
2.1. セクション名
とすることができるようにする。
記号 | 意味 |
---|---|
[$SECT_NUMS$] | セクション番号をピリオドでつないだもの。2.1 など |
[$TITLE$] | セクション名 |
※ 上記以外はそのまま出力される。
horizontal な定義リストで
[horizontal, margin-left=20, margin-bottom=10]
Foo:: bar
Baz Qux:: quux corge
のように指定することで、左マージンと下マージンを指定することができる。 指定する数字の単位は PDF point だと思う。
PDF のファイル情報の「概要」欄の項目を adoc ファイル内に
// タイトルを「PDF Title」にする
:pdf_title: PDF Title
のように書くことで、個別に指定できる。
指定可能な項目は下表の通り:
アトリビュート名 | Acrobat Reader の「概要」欄の日本語名 | 例 |
---|---|---|
pdf_title | タイトル | Starfish Wars |
pdf_author | 作成者 | 鍋谷武典 |
pdf_subject | サブタイトル | ビピンナリアの復讐 |
pdf_keywords | キーワード | ヒトデ 棘皮動物 Starfish |
pdf_producer | PDF変換 | Acrobat Distiller |
pdf_creator | アプリケーション | FrameMaker 6.0 |
テーマの yaml に
bookmark:
include-title-page: false
と書くと、表紙はしおりにふくまれないようになる。