├── articles ├── images │ ├── .gitkeep │ ├── cover.jpg │ ├── bgp-fsm.png │ ├── bgp_fsm.png │ ├── cover-a5.ai │ ├── cover-b5.ai │ ├── test-env.png │ ├── wireshark.png │ ├── tv_state_machine.png │ └── test-env ├── sty │ ├── review-custom.sty │ ├── reviewmacro.sty │ ├── review-style.sty │ ├── README.md │ ├── techbooster-doujin-base.sty │ ├── plistings.sty │ └── listings-rust.sty ├── Rakefile ├── webroot │ ├── images │ │ ├── cover.jpg │ │ ├── bgp-fsm.png │ │ ├── bgp_fsm.png │ │ ├── test-env.png │ │ ├── wireshark.png │ │ └── tv_state_machine.png │ ├── style-web.css │ ├── index.html │ ├── titlepage.html │ ├── style.css │ ├── preface.html │ └── integration_tests.html ├── locale.yml ├── prh.yml ├── .rake_tasks~ ├── catalog.yml ├── doc │ ├── writing_vertical.md │ ├── catalog.ja.md │ ├── catalog.md │ ├── customize_epub.ja.md │ ├── writing_vertical.ja.md │ ├── customize_epub.md │ ├── makeindex.ja.md │ ├── preproc.ja.md │ ├── format_idg.ja.md │ ├── preproc.md │ ├── makeindex.md │ ├── pdfmaker.md │ ├── pdfmaker.ja.md │ ├── quickstart.ja.md │ └── quickstart.md ├── images_src │ ├── tv_state_machine.uml │ └── bgp_fsm.uml ├── layouts │ └── config-local.tex.erb ├── config-ebook.yml ├── style-web.css ├── style-web.scss ├── preface.re ├── style.css ├── lib │ └── tasks │ │ ├── z01_pandoc2review.rake │ │ └── review.rake ├── style.scss ├── integration_tests.re ├── epub_style.css ├── epub_style.scss ├── learning_background.re └── exchange_update_message.re ├── .gitpod.yml ├── rebuild-css.sh ├── pdf-sample ├── TechBooster-Template-A5.pdf ├── TechBooster-Template-B5.pdf └── TechBooster-Template-ebook.pdf ├── setup.sh ├── Gemfile ├── .gitignore ├── prh-rules ├── README.md ├── languages │ └── ja │ │ └── typo.yml ├── terms │ ├── software.yml │ ├── review.yml │ ├── javascript.yml │ ├── trademark.yml │ └── android.yml ├── test.js ├── package.json ├── README.ja.md └── media │ └── techbooster.yml ├── .gitlab-ci.yml ├── .github └── workflows │ └── on_push.yml ├── README.md ├── package.json ├── redpen-conf-ja.xml ├── Gruntfile.js └── .circleci └── config.yml /articles/images/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /articles/sty/review-custom.sty: -------------------------------------------------------------------------------- 1 | % for user-defined macro 2 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | image: vvakame/review:5.3 2 | tasks: 3 | - command: ./setup.sh 4 | -------------------------------------------------------------------------------- /articles/Rakefile: -------------------------------------------------------------------------------- 1 | Dir.glob('lib/tasks/*.rake').sort.each do |file| 2 | load(file) 3 | end 4 | -------------------------------------------------------------------------------- /articles/images/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/images/cover.jpg -------------------------------------------------------------------------------- /articles/images/bgp-fsm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/images/bgp-fsm.png -------------------------------------------------------------------------------- /articles/images/bgp_fsm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/images/bgp_fsm.png -------------------------------------------------------------------------------- /articles/images/cover-a5.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/images/cover-a5.ai -------------------------------------------------------------------------------- /articles/images/cover-b5.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/images/cover-b5.ai -------------------------------------------------------------------------------- /articles/images/test-env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/images/test-env.png -------------------------------------------------------------------------------- /rebuild-css.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | npm install --no-save node-sass 3 | $(npm bin)/node-sass ./articles/ --output ./articles/ 4 | -------------------------------------------------------------------------------- /articles/images/wireshark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/images/wireshark.png -------------------------------------------------------------------------------- /articles/webroot/images/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/webroot/images/cover.jpg -------------------------------------------------------------------------------- /articles/locale.yml: -------------------------------------------------------------------------------- 1 | locale: ja 2 | column_head: ■コラム 3 | columnname: コラム 4 | memo_head: ■メモ 5 | image: 図 6 | table: 表 7 | list: リスト 8 | -------------------------------------------------------------------------------- /articles/webroot/images/bgp-fsm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/webroot/images/bgp-fsm.png -------------------------------------------------------------------------------- /articles/webroot/images/bgp_fsm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/webroot/images/bgp_fsm.png -------------------------------------------------------------------------------- /articles/images/tv_state_machine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/images/tv_state_machine.png -------------------------------------------------------------------------------- /articles/webroot/images/test-env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/webroot/images/test-env.png -------------------------------------------------------------------------------- /articles/webroot/images/wireshark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/webroot/images/wireshark.png -------------------------------------------------------------------------------- /pdf-sample/TechBooster-Template-A5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/pdf-sample/TechBooster-Template-A5.pdf -------------------------------------------------------------------------------- /pdf-sample/TechBooster-Template-B5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/pdf-sample/TechBooster-Template-B5.pdf -------------------------------------------------------------------------------- /pdf-sample/TechBooster-Template-ebook.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/pdf-sample/TechBooster-Template-ebook.pdf -------------------------------------------------------------------------------- /articles/webroot/images/tv_state_machine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Miyoshi-Ryota/how-to-create-bgp/HEAD/articles/webroot/images/tv_state_machine.png -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eux 4 | 5 | rm -rf node_modules 6 | # --unsafe-perm はrootでの実行時(= docker環境)で必要 非root時の挙動に影響なし 7 | npm install --unsafe-perm 8 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # A sample Gemfile 2 | source "https://rubygems.org" 3 | 4 | gem 'review', '5.3.0' 5 | gem 'pandoc2review' 6 | gem 'rake' 7 | # gem 'review-peg', '0.2.2' 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | Gemfile.lock 3 | *.pdf 4 | .sass-cache/ 5 | 6 | articles/*.pdf 7 | articles/*.epub 8 | articles/*.html 9 | # articles/*.md 10 | articles/*.xml 11 | articles/*.txt 12 | -------------------------------------------------------------------------------- /articles/prh.yml: -------------------------------------------------------------------------------- 1 | # https://gist.github.com/inao/f55e8232e150aee918b9 2 | # from WEB+DB PRESS 3 | # 対応は不完全(途中で飽きた) 一部手心を加えている 4 | version: 1 5 | 6 | imports: 7 | # 気合で移行した気持ちになった 8 | - ../prh-rules/media/techbooster.yml 9 | -------------------------------------------------------------------------------- /prh-rules/README.md: -------------------------------------------------------------------------------- 1 | # A collection of prh rules [![CircleCI](https://circleci.com/gh/prh/rules.svg?style=svg)](https://circleci.com/gh/prh/rules) 2 | 3 | [in japanese](https://github.com/prh/rules/blob/master/README.ja.md) 4 | -------------------------------------------------------------------------------- /articles/.rake_tasks~: -------------------------------------------------------------------------------- 1 | all 2 | clean 3 | clobber 4 | epub 5 | html 6 | html_all 7 | idgxml 8 | pandoc2review 9 | pdf 10 | plaintext 11 | preproc 12 | text 13 | vivliostyle 14 | vivliostyle:build 15 | vivliostyle:preview 16 | web 17 | -------------------------------------------------------------------------------- /prh-rules/languages/ja/typo.yml: -------------------------------------------------------------------------------- 1 | # Rules for Japanese typo 2 | meta: 3 | reviewer: 4 | - vvakame 5 | - mhidaka 6 | rules: https://github.com/prh/rules 7 | 8 | version: 1 9 | rules: 10 | - expected: なるほど 11 | pattern: なほるど 12 | -------------------------------------------------------------------------------- /articles/catalog.yml: -------------------------------------------------------------------------------- 1 | PREDEF: 2 | - preface.re 3 | 4 | CHAPS: 5 | - learning_background.re 6 | - starting_point.re 7 | - integration_tests.re 8 | - established.re 9 | - exchange_update_message.re 10 | 11 | APPENDIX: 12 | 13 | POSTDEF: 14 | 15 | -------------------------------------------------------------------------------- /prh-rules/terms/software.yml: -------------------------------------------------------------------------------- 1 | # Rules for Software Development 2 | meta: 3 | reviewer: 4 | - vvakame 5 | - mhidaka 6 | rules: https://github.com/prh/rules 7 | 8 | version: 1 9 | rules: 10 | - expected: Web 11 | - expected: superset 12 | pattern: super set 13 | -------------------------------------------------------------------------------- /articles/doc/writing_vertical.md: -------------------------------------------------------------------------------- 1 | # Supporing Vertical Writing (experimental) 2 | 3 | From Re:VIEW 2.0, Re:VIEW supports vertical writings, especially for Japanese document. 4 | 5 | If you need any further information, please read [writing_vertical.ja.md](writing_vertical.ja.md) (in Japanese). 6 | -------------------------------------------------------------------------------- /articles/images_src/tv_state_machine.uml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | state 電源OFF 4 | 5 | state 電源ON 6 | 7 | 電源OFF --> 電源ON : 電源ボタンの押下 8 | 電源OFF --> 電源OFF : 音量増加ボタンの押下 9 | 電源OFF --> 電源OFF : 音量減少ボタンの押下 10 | 電源ON --> 電源OFF : 電源ボタンの押下 11 | 電源ON --> 電源ON : 音量増加ボタンの押下 12 | 電源ON --> 電源ON : 音量減少ボタンの押下 13 | 14 | @enduml 15 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: vvakame/review:5.3 2 | 3 | build-pdf: 4 | script: # build-in-docker.sh の終盤と同じもの 5 | - ./setup.sh 6 | - npm run pdf 7 | artifacts: 8 | paths: 9 | - articles/ReVIEW-Template.pdf 10 | tags: 11 | - docker 12 | 13 | # 文法はこちらを参照してください 14 | # https://docs.gitlab.com/ce/ci/yaml/README.html 15 | -------------------------------------------------------------------------------- /articles/layouts/config-local.tex.erb: -------------------------------------------------------------------------------- 1 | \makeatletter 2 | <%- if @config['techbooster'] && @config['techbooster']['cover_fit_page'] -%> 3 | \recls@coverfitpagetrue 4 | <%- end -%> 5 | <%- if @config['techbooster'] && @config['techbooster']['backcoverimage'] -%> 6 | \def\techbooster@coverimage{images/<%= @config['techbooster']['backcoverimage'] %>} 7 | <%- end -%> 8 | \makeatother 9 | -------------------------------------------------------------------------------- /prh-rules/terms/review.yml: -------------------------------------------------------------------------------- 1 | # Rules for Re:VIEW 2 | meta: 3 | reviewer: 4 | - vvakame 5 | - mhidaka 6 | related: https://github.com/kmuto/review/ 7 | rules: https://github.com/prh/rules 8 | 9 | version: 1 10 | rules: 11 | - expected: "@<$1>{$2}" # 先頭 @ はyaml的にアレなのでダブルクォートで囲む 12 | pattern: /@([^{<>]+)\{([^}]+)\}/ 13 | specs: 14 | - from: "@list{foo}" 15 | to: "@{foo}" 16 | - from: "@{foo}" 17 | to: "@{foo}" 18 | prh: Re:VIEW記法の書き方を間違えていませんか? 19 | -------------------------------------------------------------------------------- /prh-rules/terms/javascript.yml: -------------------------------------------------------------------------------- 1 | # Rules for JavaScript 2 | meta: 3 | reviewer: 4 | - vvakame 5 | related: http://www.ecma-international.org/publications/standards/Ecma-262.htm 6 | rules: https://github.com/prh/rules 7 | 8 | version: 1 9 | rules: 10 | - expected: jQuery 11 | - expected: Angular 2 12 | pattern: Angular2 13 | - expected: Web Components 14 | pattern: WebComponents 15 | - expected: Custom Elements 16 | pattern: CustomElements 17 | - expected: Shadow DOM 18 | pattern: ShadowDOM 19 | - expected: Incremental DOM 20 | pattern: IncrementalDOM 21 | -------------------------------------------------------------------------------- /prh-rules/test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const expand = require("glob-expand"); 4 | const prh = require("prh"); 5 | const assert = require("assert"); 6 | 7 | const ymlList = expand({ filter: "isFile", cwd: __dirname }, [ 8 | "**/*.yml", 9 | "!node_modules/**", 10 | ]); 11 | 12 | ymlList.forEach(yml => { 13 | try { 14 | const engine = prh.fromYAMLFilePath(yml); 15 | const changeSet = engine.makeChangeSet("./README.ja.md"); 16 | } catch (e) { 17 | console.log(`processing... ${yml}\n`); 18 | throw e; 19 | } 20 | }); 21 | 22 | console.log("😸 done"); 23 | -------------------------------------------------------------------------------- /articles/sty/reviewmacro.sty: -------------------------------------------------------------------------------- 1 | % Re:VIEW 2互換のlayout.tex.erb記載相当の内容 2 | \RequirePackage{review-base} 3 | 4 | % Re:VIEW 2互換のreviewmacro.sty(装飾カスタマイズ)内容 5 | \RequirePackage{review-style} 6 | 7 | % TechBooster固有マクロ 8 | \RequirePackage{techbooster-doujin-base} 9 | 10 | % 囲み飾りの設定 11 | \ifdefined\reviewboxsetting% 12 | \RequirePackage{review-tcbox} 13 | \fi 14 | 15 | % ユーザー固有の定義 16 | \RequirePackage{review-custom} 17 | 18 | %% run \@endofreviewmacrohook at the end of reviewmacro style 19 | \@ifundefined{@endofreviewmacrohook}{}{% 20 | \let\AtEndOfReVIEWMacro\@firstofone 21 | \@endofreviewmacrohook} 22 | 23 | \endinput 24 | -------------------------------------------------------------------------------- /prh-rules/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prh-rules", 3 | "private": true, 4 | "version": "1.0.0", 5 | "description": "", 6 | "scripts": { 7 | "test": "node test.js" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/prh/rules.git" 12 | }, 13 | "author": "vvakame", 14 | "license": "MIT", 15 | "bugs": { 16 | "url": "https://github.com/prh/rules/issues" 17 | }, 18 | "homepage": "https://github.com/prh/rules#readme", 19 | "dependencies": { 20 | "prh": "^1.0.3" 21 | }, 22 | "devDependencies": { 23 | "glob-expand": "^0.2.1" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /prh-rules/README.ja.md: -------------------------------------------------------------------------------- 1 | # A collection of prh rules [![CircleCI](https://circleci.com/gh/prh/rules.svg?style=svg)](https://circleci.com/gh/prh/rules) 2 | 3 | ## フォルダ構成 4 | 5 | * languages 6 | * 各自然言語固有のルール 7 | * terms 8 | * 技術用語のルール 9 | * 商標やツールの正式名称などのルール 10 | * 各種ツール固有のルール 11 | * media 12 | * 各媒体固有のルール 13 | 14 | ## ルール 15 | 16 | * yaml内でimportを使ってはならない 17 | * rootディレクトリのprh.ymlとmediumの中は除く 18 | * 原則として、media内のルールを他のファイルから参照しない(組み合わせて運用する前提のものではないため) 19 | * mediaには原則として、各団体・出版社別ルールを置く 20 | * 作品別ルールは作品のリポジトリにて個別に管理するのを推奨する 21 | * 団体内部で複数のファイルを置きたい場合、 media/techbooster/ のように団体名のディレクトリを切ってその中で自由にすること 22 | -------------------------------------------------------------------------------- /.github/workflows/on_push.yml: -------------------------------------------------------------------------------- 1 | name: Build Re:VIEW to make distribution file 2 | # The workflow is triggered on pushes to the repository. 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | name: 8 | runs-on: ubuntu-latest 9 | steps: 10 | # uses v2 Stable version 11 | # https://github.com/actions/checkout 12 | - name: checkout source 13 | uses: actions/checkout@v2 14 | # Build Artifacts 15 | - name: Build distribution file 16 | uses: TechBooster/ReVIEW-build-artifact-action@master 17 | # Upload Distribution file 18 | - name: Upload distribution file to github artifacts 19 | uses: actions/upload-artifact@v2 20 | with: 21 | name: Output documents 22 | path: ./articles/*.pdf -------------------------------------------------------------------------------- /prh-rules/terms/trademark.yml: -------------------------------------------------------------------------------- 1 | # Rules for Trademark 2 | meta: 3 | reviewer: 4 | - vvakame 5 | - mhidaka 6 | rules: https://github.com/prh/rules 7 | 8 | version: 1 9 | rules: 10 | - expected: Re:VIEW 11 | pattern: /ReVIEW/ 12 | specs: 13 | - from: ReVIEW 14 | to: Re:VIEW 15 | - from: review 16 | to: review 17 | - expected: 技術書典 18 | pattern: /技術書(店|…|点|展|てん)/ 19 | specs: 20 | - from: 技術書点 21 | to: 技術書典 22 | - from: 技術書展 23 | to: 技術書典 24 | - expected: American Express(Amex) 25 | pattern: 26 | - アメリカン・エキスプレス 27 | - アメックス 28 | - アメリカンエクスプレス 29 | - expected: 技術書典 30 | pattern: /技術書(店|…|点|展|てん)/ 31 | specs: 32 | - from: 技術書点 33 | to: 技術書典 34 | - from: 技術書展 35 | to: 技術書典 36 | -------------------------------------------------------------------------------- /articles/config-ebook.yml: -------------------------------------------------------------------------------- 1 | # 電子版用の上書き設定 2 | # 以下のいずれかのコマンドでPDFをビルドできる 3 | # - REVIEW_CONFIG_FILE=config-ebook.yml rake pdf 4 | # - review-pdfmaker config-ebook.yml 5 | # - REVIEW_CONFIG_FILE=config-ebook.yml npm run pdf 6 | 7 | # 継承元設定 8 | inherit: ["config.yml"] 9 | 10 | # 電子版を別のファイル名にしたい場合 11 | # bookname: ReVIEW-Template-ebook 12 | 13 | # B5の設定(10pt 40文字×35行) - 電子版 14 | texdocumentclass: ["review-jsbook", "media=ebook,paper=b5,serial_pagination=true,openany,fontsize=10pt,baselineskip=15.4pt,line_length=40zw,number_of_lines=35,head_space=30mm,headsep=10mm,headheight=5mm,footskip=10mm"] 15 | # A5の設定(9pt 38文字×37行) - 電子版 16 | # texdocumentclass: ["review-jsbook", "media=ebook,paper=a5,serial_pagination=true,openany,fontsize=9pt,baselineskip=13pt,line_length=38zw,number_of_lines=37,head_space=15mm,headsep=3mm,headheight=5mm,footskip=10mm"] 17 | -------------------------------------------------------------------------------- /articles/images_src/bgp_fsm.uml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | state Idle 4 | state Connect 5 | state OpenConfirm 6 | state OpenSent 7 | state Established 8 | 9 | [*] --> Idle 10 | Idle --> Connect : ManualStart event 11 | note on link 12 | 対向側機器とTCPコネクションを作成を試みる。 13 | end note 14 | Connect --> OpenSent : Tcp_CR_Acked | TcpConnectionConfirmed event 15 | note on link 16 | 対向側機器にBGP OpenMessageを送信する。 17 | end note 18 | OpenSent --> OpenConfirm : BGPOpen event 19 | note on link 20 | 対向機器にBGP Keepalive Messageを送信する。 21 | end note 22 | OpenConfirm --> Established : KeepAliveMsg event 23 | Established --> Established : Established event 24 | Established --> Established : LocRibChanged event 25 | Established --> Established : AdjRibOutChanged event 26 | Established --> Established : UpdateMsg event 27 | Established --> Established : AdjRibInChanged event 28 | @enduml 29 | -------------------------------------------------------------------------------- /prh-rules/terms/android.yml: -------------------------------------------------------------------------------- 1 | # Rules for Android 2 | meta: 3 | reviewer: 4 | - vvakame 5 | - mhidaka 6 | related: https://www.android.com/ 7 | rules: https://github.com/prh/rules 8 | 9 | version: 1 10 | rules: 11 | - expected: API Level 12 | pattern: API level 13 | prh: APIドキュメントでも揺れてますが、Levelで統一してます 14 | - expected: Android Studio 15 | pattern: AndroidStudio 16 | prh: 正式名称はAndroid Studioです 17 | - expected: JUnit 5 18 | pattern: JUnit5 19 | - expected: JUnit 4 20 | pattern: JUnit4 21 | - expected: View 22 | pattern: Vew 23 | - expected: Deep Link 24 | pattern: DeepLink 25 | - expected: Jetpack 26 | pattern: JetPack 27 | - expected: aidl 28 | pattern: /adil/ 29 | - expected: AIDL 30 | pattern: /ADIL/ 31 | - expected: Safe Args 32 | pattern: safeargs 33 | - expected: Navigation 34 | pattern: Navigtion 35 | -------------------------------------------------------------------------------- /articles/doc/catalog.ja.md: -------------------------------------------------------------------------------- 1 | # Re:VIEW カタログファイル ガイド 2 | 3 | Re:VIEW のカタログファイル catalog.yml について説明します。 4 | 5 | このドキュメントは、Re:VIEW 2.0 に基づいています。 6 | 7 | ## カタログファイルとは 8 | 9 | カタログファイルは、Re:VIEW フォーマットで記述された各ファイルを1冊の本(たとえば PDF や EPUB)にまとめる際に、どのようにそれらのファイルを構造化するかを指定するファイルです。現在はカタログファイルと言えば catalog.yml のことを指します。 10 | 11 | ## catalog.yml を用いた場合の設定方法 12 | 13 | catalog.yml 内で、`PREDEF`(前付け)、`CHAPS`(本編)、`APPENDIX`(付録、連番あり)、`POSTDEF`(後付け、連番なし)を記述します。CHAPS のみ必須です。 14 | 15 | ```yaml 16 | PREDEF: 17 | - intro.re 18 | 19 | CHAPS: 20 | - ch01.re 21 | - ch02.re 22 | 23 | APPENDIX: 24 | - appendix.re 25 | 26 | POSTDEF: 27 | - postscript.re 28 | ``` 29 | 30 | 本編に対して、「部」構成を加えたい場合、`CHAPS` を段階的にして記述します。部の指定については、タイトル名でもファイル名でもどちらでも使えます。 31 | 32 | ```yaml 33 | CHAPS: 34 | - ch01.re 35 | - 第1部: 36 | - ch02.re 37 | - ch03.re 38 | - pt02.re: 39 | - ch04.re 40 | ``` 41 | 42 | ## 古いバージョンについて 43 | 1.2 以前の Re:VIEW ではカタログファイルとして PREDEF, CHAPS, POSTDEF, PART という独立した4つのファイルを使用していました。古いカタログファイルを変換するツールとして、`review-catalog-converter` を提供しています。 44 | 45 | このコマンドにドキュメントのパスを指定して実行後、生成された catalog.yml の内容が正しいか確認してください。 46 | -------------------------------------------------------------------------------- /articles/style-web.css: -------------------------------------------------------------------------------- 1 | /* stylesheet for Re:VIEW web */ 2 | nav.side-content { 3 | width: 200px; 4 | position: fixed; } 5 | nav.side-content h1.side-title { 6 | margin: 0; 7 | padding: 0; 8 | font-size: 1em; 9 | border-top: none; } 10 | nav.side-content ul { 11 | list-style: none; } 12 | 13 | .book-body { 14 | margin-left: 240px; 15 | margin-right: 40px; 16 | position: relative; } 17 | .book-body .book-page { 18 | max-width: 800px; 19 | margin: 0 auto; 20 | padding: 32px 0 32px; } 21 | .book-body .book-navi { 22 | position: fixed; 23 | top: 0; 24 | min-width: 40px; } 25 | .book-body .book-navi a { 26 | text-decoration: none; } 27 | .book-body .book-prev { 28 | left: 210px; } 29 | .book-body .book-next { 30 | right: 10px; } 31 | .book-body .book-cursor { 32 | height: 100vh; 33 | text-align: center; 34 | font-size: 32pt; 35 | padding: 100px 0 0 0; 36 | color: #eee; } 37 | .book-body .book-cursor:hover { 38 | color: #333; } 39 | 40 | footer p { 41 | margin-left: 240px; 42 | text-align: center; } 43 | 44 | .cover-image img { 45 | max-width: 100%; } 46 | -------------------------------------------------------------------------------- /articles/webroot/style-web.css: -------------------------------------------------------------------------------- 1 | /* stylesheet for Re:VIEW web */ 2 | nav.side-content { 3 | width: 200px; 4 | position: fixed; } 5 | nav.side-content h1.side-title { 6 | margin: 0; 7 | padding: 0; 8 | font-size: 1em; 9 | border-top: none; } 10 | nav.side-content ul { 11 | list-style: none; } 12 | 13 | .book-body { 14 | margin-left: 240px; 15 | margin-right: 40px; 16 | position: relative; } 17 | .book-body .book-page { 18 | max-width: 800px; 19 | margin: 0 auto; 20 | padding: 32px 0 32px; } 21 | .book-body .book-navi { 22 | position: fixed; 23 | top: 0; 24 | min-width: 40px; } 25 | .book-body .book-navi a { 26 | text-decoration: none; } 27 | .book-body .book-prev { 28 | left: 210px; } 29 | .book-body .book-next { 30 | right: 10px; } 31 | .book-body .book-cursor { 32 | height: 100vh; 33 | text-align: center; 34 | font-size: 32pt; 35 | padding: 100px 0 0 0; 36 | color: #eee; } 37 | .book-body .book-cursor:hover { 38 | color: #333; } 39 | 40 | footer p { 41 | margin-left: 240px; 42 | text-align: center; } 43 | 44 | .cover-image img { 45 | max-width: 100%; } 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 作って学ぶルーティングプロトコル〜RustでBGPを実装〜 2 | 3 | 本リポジトリは、「作って学ぶルーティングプロトコル〜RustでBGPを実装〜」の原稿を管理するリポジトリです。 本書は同人版と商業版が存在します。 4 | 本リポジトリでは、同人版の原稿が上がっています。 5 | 6 | 無料で読みたい場合はこのリポジトリの内容を自力でビルドすることで読むことが可能ですが、商業版では、大量のバグ・誤記が修正され、解説が大量に追加されているため、商業版を読むことをおすすめします。 7 | 8 | ページ数で言えば、46ページから100ページ越えへ大幅に加筆されています。商業版は以下で購入が可能です。 9 | 10 | https://www.amazon.co.jp/gp/product/B0BN9TBQB6/ref=as_li_tf_tl?ie=UTF8&camp=247&creative=1211&creativeASIN=B0BN9TBQB6&linkCode=as2&tag=impressrd-1-22 11 | ![]( "サンプル") 12 | 13 | [![cover](https://m.media-amazon.com/images/P/B0BN9TBQB6.01._SCLZZZZZZZ_SX500_.jpg)](https://www.amazon.co.jp/gp/product/B0BN9TBQB6/) 14 | 15 | 16 | ## 商業版の正誤表 17 | 18 | 商業版の正誤表は以下に公開されております。 19 | 20 | https://miyoshi-ryota.github.io/mrbgpdv2/ 21 | 22 | ## 権利 23 | 本リポジトリは[TechBooster/ReVIEW-Template](https://github.com/TechBooster/ReVIEW-Template/)を用いて作成されています。 24 | * 設定ファイル、テンプレートなど制作環境(techbooster-doujin-base.styなど)はMITライセンスでTechBoosterが権利者です。 25 | * articles/styにあるファイルには以下のライセンスが適用されています。 26 | * review-jsbook.cls, review-base.sty, review-style.sty, review-custom.sty: MIT License 27 | * jumoline.sty: The LaTeX Project Public License 28 | * plistings.sty: MIT License 29 | * gentombow.sty: BSD License 30 | * jsbook.cls: BSD License 31 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "review-template", 3 | "version": "0.0.2", 4 | "private": true, 5 | "description": "", 6 | "main": "Gruntfile.js", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/TechBooster/ReVIEW-Template.git" 10 | }, 11 | "author": "", 12 | "license": "MIT", 13 | "bugs": { 14 | "url": "https://github.com/TechBooster/ReVIEW-Template/issues" 15 | }, 16 | "homepage": "https://github.com/TechBooster/ReVIEW-Template#readme", 17 | "engines": { 18 | "node": ">=6.0.0" 19 | }, 20 | "scripts": { 21 | "global-bundler": "gem install bundler", 22 | "global": "npm run global-bundler", 23 | "postinstall": "bundle install", 24 | "pdf": "grunt pdf", 25 | "md": "grunt markdown", 26 | "html": "grunt html", 27 | "text": "grunt text", 28 | "epub": "grunt epub", 29 | "web": "grunt web", 30 | "idgxml": "grunt idgxmlmaker", 31 | "vivliostyle": "grunt vivliostyle", 32 | "test": "npm run html" 33 | }, 34 | "dependencies": {}, 35 | "devDependencies": { 36 | "grunt": "^1.1.0", 37 | "grunt-cli": "^1.2.0", 38 | "grunt-contrib-clean": "^2.0.0", 39 | "grunt-shell": "^3.0.1", 40 | "js-yaml": "^3.13.1", 41 | "load-grunt-tasks": "^4.0.0" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /articles/doc/catalog.md: -------------------------------------------------------------------------------- 1 | # Re:VIEW catalog.yml Guide 2 | 3 | This article describes Re:VIEW catalog file catalog.yml. 4 | 5 | ## What's catalog.yml 6 | 7 | Catalog file shows the structure of files to generate books (such as PDF or EPUB) in Re:VIEW format. 8 | Now we use catalog.yml as catalog file. 9 | 10 | ## How to write catalog.yml 11 | 12 | In catalog.yml, you can write `PREDEF`(frontmatter), `CHAPS`(bodymatter), `APPENDIX`(appendix) and `POSTDEF`(backmater). `CHAPS` is required. 13 | 14 | ```yaml 15 | PREDEF: 16 | - intro.re 17 | 18 | CHAPS: 19 | - ch01.re 20 | - ch02.re 21 | 22 | APPENDIX: 23 | - appendix.re 24 | 25 | POSTDEF: 26 | - postscript.re 27 | ``` 28 | 29 | You can add parts in body to use `CHAPS` in a hierarchy. You can use both title name and file name to specify parts. 30 | 31 | ```yaml 32 | CHAPS: 33 | - ch01.re 34 | - TITLE_OF_PART1: 35 | - ch02.re 36 | - ch03.re 37 | - pt02.re: 38 | - ch04.re 39 | ``` 40 | 41 | (For old version user: there is no `PART`. You write them in `CHAPS`.) 42 | 43 | ## About earlier version 44 | 45 | In version 1.x, Re:VIEW use 4 files PREDEF, CHAPS, POSTDEF, PART as catalog files. 46 | 47 | You can convert there files with `review-catalog-converter`. 48 | When using it, you should compare with these files and the generated file `catalog.yml`. 49 | -------------------------------------------------------------------------------- /articles/images/test-env: -------------------------------------------------------------------------------- 1 | 7Vlbb5swGP01eQzCXBL6mEuzqdKkapW2bm80OGDVwcw4Ddmv3+dg7qSkVcJ4SF7Cd3w/5/gGI3OxTb5wNwq+MQ/TkaF7ychcjgwDWUiHP4kcFOLodor4nHgKK4An8hcrUBX0d8TDcSWjYIwKElXBNQtDvBYVzOWc7avZNoxWW41cHzeAp7VLm+hP4okgRR1bL/CvmPhB1jLSVcrWzTIrIA5cj+1LkHk/MhecMZE+bZMFppK9jJe03OpEat4xjkNxToFt5Duzh9WvB4J/x6vZj+fvnI5VLW8u3akBBywWCo3FIaNhHxCBnyJ3LeM9aD0y54HYUogQPLpxlJK/IQmG9uaqWswFTk72F+UsgH8w22LBD5BFFTAsRVxmnamK9yUdFBSUJMgwVynv5zUX5MCD4ucDXBmtXBlD4MoaGldmg6sGTVALTGII5jAzIgmuKdtJQjoIvARfNbomdoMuZPTJlzVsvmyn21/9EjY9g7DQm8kdAKKQhbhKCme70JPTb6lLRgVnr/kCD0TMgRh+eFbJx+CXDDQ7C5dJOXF5yKKEiGfVhnwulYKoKCSDrEzac+w1dqKaPDA6tuNr3L2eC5f7WHStZU25S3LaLWpmGMfUFeSt2t02iVULj4zAQHI3mWbVTfa05pJ0mKpUeUurV1SzpW3UKkp5aFR0dFw+7M+b0OnNhBqa1HzYaUQZPWJOYJCYf9hpnQ6y/qeDcqGV8HDS/JyDLLtWUc8Ouhv4MqZrd5NpdSmbmO8uZjL4vO06FzjzTHue2M/6sSdCNVfVt8Fz7YmcO83QSz/7/Xqv7FbUvC6MjAkV0nqRG1Z8O/mzkzeb+YaFYhwf73UzyICsKCkS4cmX/8eD9DjEYs/4a1blC8+SEax/uq7B5NRgwCvDambJEEhOu5LBtdkEZyBRnULppFkwyngxxTaE0hrkUuKH8tQFnpXOnssTFYGb4kwlbInnyWZaz2PViXqJI1ltE80913UkM691JEPNC9Ll3IG63YFu7igWDmNw7mi7El7CHS9+NBY4Fu8aBBbRo0luBjlxBh+AQdruwJcwiGbc9C4OtsWL2Ibe/cpt3+S+4vQenNyTa8lt3uQ2zKnTKXf+ZaIfvdte0N30vpDeVv197BX1hrD4SJXeJItvfeb9Pw== -------------------------------------------------------------------------------- /articles/style-web.scss: -------------------------------------------------------------------------------- 1 | /* stylesheet for Re:VIEW web */ 2 | 3 | $cursor-top: 100px; 4 | $cursor-width: 40px; 5 | $side-width: 200px; 6 | $page-width: 800px; 7 | 8 | nav.side-content 9 | { 10 | 11 | width: $side-width; 12 | position: fixed; 13 | 14 | h1.side-title 15 | { 16 | margin: 0; 17 | padding: 0; 18 | font-size: 1em; 19 | border-top: none; 20 | } 21 | 22 | ul 23 | { 24 | list-style: none; 25 | } 26 | } 27 | 28 | .book-body 29 | { 30 | margin-left: $cursor-width + $side-width; 31 | margin-right: $cursor-width; 32 | position: relative; 33 | 34 | .book-page 35 | { 36 | max-width: $page-width; 37 | margin:0 auto; 38 | padding: 32px 0 32px; 39 | } 40 | 41 | .book-navi 42 | { 43 | position: fixed; 44 | top: 0; 45 | min-width: $cursor-width; 46 | 47 | a 48 | { 49 | text-decoration: none; 50 | } 51 | } 52 | 53 | .book-prev 54 | { 55 | left: $side-width + 10px; 56 | } 57 | .book-next 58 | { 59 | right: 10px; 60 | } 61 | 62 | .book-cursor 63 | { 64 | height: 100vh; 65 | text-align: center; 66 | font-size: 32pt; 67 | padding: $cursor-top 0 0 0; 68 | color: #eee; 69 | } 70 | .book-cursor:hover 71 | { 72 | color: #333; 73 | } 74 | 75 | } 76 | 77 | footer p 78 | { 79 | margin-left: $side-width + $cursor-width; 80 | text-align: center; 81 | } 82 | 83 | .cover-image img 84 | { 85 | max-width: 100%; 86 | } 87 | 88 | -------------------------------------------------------------------------------- /articles/sty/review-style.sty: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e} 2 | \ProvidesPackage{review-style}[2021/01/06] 3 | 4 | \RequirePackage{fancyhdr} 5 | \pagestyle{fancy} 6 | \lhead{\gtfamily\sffamily\bfseries\upshape \leftmark} 7 | \chead{} 8 | \rhead{\gtfamily\sffamily\bfseries\upshape \rightmark} 9 | \fancyfoot{} % clear all header and footer fields 10 | \fancyfoot[LE,RO]{\thepage} 11 | \renewcommand{\sectionmark}[1]{\markright{\thesection~#1}{}} 12 | \renewcommand{\chaptermark}[1]{\markboth{\prechaptername\ \thechapter\ \postchaptername~#1}{}} 13 | \renewcommand{\headfont}{\gtfamily\sffamily\bfseries} 14 | 15 | \fancypagestyle{plainhead}{% 16 | \fancyhead{} 17 | \fancyfoot{} % clear all header and footer fields 18 | \fancyfoot[LE,RO]{\thepage} 19 | \renewcommand{\headrulewidth}{0pt} 20 | \renewcommand{\footrulewidth}{0pt}} 21 | 22 | %% using Helvetica as sans-serif 23 | \renewcommand{\sfdefault}{phv} 24 | 25 | %% for listings 26 | %\renewcommand{\lstlistingname}{List} 27 | %\lstset{% 28 | % breaklines=true,% 29 | % breakautoindent=false,% 30 | % breakindent=0pt,% 31 | % fontadjust=true,% 32 | % backgroundcolor=\color{shadecolor},% 33 | % frame=single,% 34 | % framerule=0pt,% 35 | % basicstyle=\ttfamily\scriptsize,% 36 | % commentstyle=\color{reviewgreen},% 37 | % identifierstyle=\color{reviewblue},% 38 | % stringstyle=\color{reviewred},% 39 | % keywordstyle=\bfseries\color{reviewdarkred},% 40 | %} 41 | 42 | %% disable hyperlink color and border 43 | \hypersetup{hidelinks} 44 | 45 | \floatplacement{figure}{H} 46 | \floatplacement{table}{H} 47 | 48 | % space between English/Japanese characters in list environments (\z@ means 0, no space. You can comment out below line for backward compatibility.) 49 | \def\reviewlistxkanjiskip{\z@} 50 | 51 | % boxsetting 52 | \ifdefined\reviewboxsetting 53 | \reviewboxsetting 54 | \fi 55 | -------------------------------------------------------------------------------- /articles/webroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | index | 作って学ぶルーティングプロトコル〜RustでBGPを実装〜 10 | 11 | 12 |
13 | 26 |
27 |
28 |
29 |
30 |
31 | 32 |
33 |
34 | 36 | 41 |
42 |
43 |
44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /articles/webroot/titlepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | titlepage | 作って学ぶルーティングプロトコル〜RustでBGPを実装〜 10 | 11 | 12 |
13 | 26 |
27 |
28 |
29 |
30 |

作って学ぶルーティングプロトコル〜RustでBGPを実装〜

mr-csce(@llp_qlv)

31 | 33 | 38 |
39 |
40 |
41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /articles/preface.re: -------------------------------------------------------------------------------- 1 | = 前書き 2 | 3 | インターネットを支えるルーティングプロトコルであるBGP(Border Gateway Protocol)をRFCからRustで実装する方法を解説します。小さなプログラムから始め、Update Messageを交換しルーティングテーブルの更新を行うまで、ステップバイステップで実装を追うことができるように解説します。 4 | 5 | 本PDFでは正常系のみ実装します。また可能な限り最小限の実装をします。 6 | 7 | また、本PDFで作成するBGPのサンプル実装・本PDFの自体のソースコードは以下リポジトリに公開しております。 8 | 9 | * https://github.com/Miyoshi-Ryota/mrbgpdv2 10 | * https://github.com/Miyoshi-Ryota/how-to-create-bgp 11 | 12 | GitHub Starをいただけたら@{とっても・とっても}嬉しいです! 13 | 14 | RFCに定義されているようなプロトコルを一度自分の手で実装することで、 15 | BGPに限らず、その他のプロトコルについてもRFCから実装できるようになるように思います。 16 | 17 | 本PDFがBGPを実装する手助け、ひいてはRFCを読めるようになること、RFCからプロトコルを実装できるようになることの手助けになることを祈っております。 18 | 19 | ぜひ楽しんでいただけたら幸いです。 20 | 21 | == 対象読者 22 | 読者に以下の前提知識を求めています。 23 | 24 | * ルーティングプロトコルは聞いたことがある。 25 | * スタティックルートとは何か分かる。 26 | * ルーティングテーブルを見て意味が分かる。 27 | * 何らかのプログラミング言語でのプログラミング経験 28 | * Rustを知っている。 29 | 30 | 以下の経験があるとよりわかりやすいかもしれません。 31 | 32 | * BGPの運用経験 33 | * Docker、docker-composeを用いた開発経験 34 | * wiresharkを用いてパケットキャプチャを行った経験 35 | 36 | == 書いていないこと 37 | 38 | 本PDFには以下のことは書かれておりません。 39 | 40 | * BGPとは何かということについての詳細な説明 41 | ** ただし、参考になるWebページを紹介しています。そのためBGPについて知らなくても問題ありません。またBGPのRFC内で説明されていることについても書内で説明しきらずURLや項目番号の紹介にとどめている部分もあります。RFCだけでは理解が難しい部分については解説しているつもりです。 42 | * Rustの文法解説 43 | * Rust / Docker / docker-compose / wiresharkなど本PDFに登場するツールのインストール方法 44 | * すべてのコードの詳細な解説。 45 | ** 繰り返し似たようなコードを書く部分があります。それらについては書内にすべてのコードを記載していません。GitHubのPRへのURLなどで済ませている部分があります。 46 | 47 | == 本PDFの動作環境 48 | 筆者は以下の環境で本PDFのサンプルプログラムの作成・動作環境を行っております。 49 | 50 | * Ubuntu 20.04 LTS / Pop!_OS 20.04 LTS 51 | * cargo 1.53.0-nightly (f3e13226d 2021-04-30) 52 | * rustc 1.54.0-nightly (676ee1472 2021-05-06) 53 | 54 | cargo / rustcのバージョンは2018 Edition以降であれば何でも動作すると考えております。 55 | 56 | ただしOSについては注意点があります。 57 | ルーティングプロトコルを実装するため、ルーティングテーブルを読み書きする処理が存在します。 58 | ルーティングテーブルの読み書きの方法はOSによって異なります。そのため、本PDFの後半ではLinuxの環境が必要になります。 59 | 仮想マシン等でも問題ありません。 60 | 61 | == 本PDFに関する問い合わせ 62 | 本PDF記載の内容に関しての質問・問い合わせ等は、Twitter: @llp_qlv 宛へのリプライ・DM、もしくはGitHubのIssueから受け付けています。 63 | -------------------------------------------------------------------------------- /articles/doc/customize_epub.ja.md: -------------------------------------------------------------------------------- 1 | # EPUB ローカルルールへの対応方法 2 | Re:VIEW の review-epubmaker が生成する EPUB ファイルは IDPF 標準に従っており、EpubCheck を通過する正規のものです。 3 | 4 | しかし、ストアによってはこれに固有のローカルルールを設けていることがあり、それに合わせるためには別途 EPUB ファイルに手を入れる必要があります。幸い、ほとんどのルールは EPUB 内のメタ情報ファイルである OPF ファイルにいくつかの情報を加えることで対処できます。 5 | 6 | Re:VIEW の設定ファイルは config.yml を使うものとします。 7 | 8 | ## 電書協ガイドライン 9 | * http://ebpaj.jp/counsel/guide 10 | 11 | 電書協ガイドラインの必須属性を満たすには、次の設定を config.yml に加えます。 12 | 13 | ```yaml 14 | opf_prefix: {ebpaj: "http://www.ebpaj.jp/"} 15 | opf_meta: {"ebpaj:guide-version": "1.1.3"} 16 | ``` 17 | 18 | これは次のように展開されます。 19 | 20 | ```xml 21 | 22 | …… 23 | 1.1.3 24 | ``` 25 | 26 | ただし、Re:VIEW の生成する EPUB は、ファイルやフォルダの構成、スタイルシートの使い方などにおいて電書協ガイドラインには準拠していません。 27 | 28 | ## iBooks ストア 29 | デフォルトでは、iBooks で EPUB を見開きで開くと、左右ページの間に影が入ります。 30 | これを消すには、次のように指定します。 31 | 32 | ```yaml 33 | opf_prefix: {ibooks: "http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/"} 34 | opf_meta: {"ibooks:binding": "false"} 35 | ``` 36 | 37 | すでにほかの定義があるときには、たとえば次のように追加してください。 38 | 39 | ```yaml 40 | opf_prefix: {ebpaj: "http://www.ebpaj.jp/", ibooks: "http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/"} 41 | opf_meta: {"ebpaj:guide-version": "1.1.3", "ibooks:binding": "false"} 42 | ``` 43 | 44 | ## Amazon Kindle 45 | 46 | EPUB を作成したあと、mobi ファイルにする必要があります。これには Amazon が無料で配布している KindleGen を使用します。 47 | 48 | - https://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211 49 | 50 | OS に合わせたインストーラでインストールした後、`kindlegen EPUBファイル` で mobi ファイルに変換できます。 51 | 52 | Kindle Previewer にも内包されています。 53 | 54 | - https://kdp.amazon.co.jp/ja_JP/help/topic/G202131170 55 | 56 | 注意点として、KindleGen は論理目次だけだとエラーを報告します。物理目次ページを付けるために、次のように config.yml に設定します。 57 | 58 | ```yaml 59 | epubmaker: 60 | toc: true 61 | ``` 62 | 63 | CSS によっては、Kindle では表現できないことについての警告が表示されることがあります。「Amazon Kindle パブリッシング・ガイドライン」では、使用可能な文字・外部ハイパーリンクの制約・色の使い方・画像サイズなどが詳細に説明されています。 64 | 65 | - http://kindlegen.s3.amazonaws.com/AmazonKindlePublishingGuidelines_JP.pdf 66 | -------------------------------------------------------------------------------- /articles/doc/writing_vertical.ja.md: -------------------------------------------------------------------------------- 1 | # 縦書きのサポート(実験的) 2 | 3 | Re:VIEW 2.0 より、縦書きの実験的なサポートを含めています。このドキュメントでその利用方法を説明します。 4 | 5 | このドキュメントは、Re:VIEW 3.0 に基づいています。 6 | 7 | ## Re:VIEW フォーマットテキストファイルでの利用 8 | 縦書きのドキュメントをサポートするため、次のような機能を提供します。 9 | 10 | ### 縦中横文字 11 | 縦書き中の1〜2文字を横置きに回転させる目的で、インライン命令 `@` を用意しました。 12 | 13 | ``` 14 | @{縦中横化する文字} 15 | ``` 16 | 17 | 図表などの大きなブロックを回転させる用途ではありません。2桁の半角アラビア数字などのごく小さな箇所の回転に対応するものです。 18 | 19 | ### 採番の漢数字や全角対応 20 | locale.yml の番号付けに縦書き向けの以下のカスタムフォーマットを用意しています。 21 | 22 | * `%pAW` : アルファベット(大文字・いわゆる全角)A, B, C, ... 23 | * `%paW` : アルファベット(小文字・いわゆる全角)a, b, c, ... 24 | * `%pJ` : 漢数字 一, 二, 三, ... 25 | * `%pdW' : アラビア数字(0〜9まではいわゆる全角、10以降半角)1, 2, ... 10, ... 26 | * `%pDW' : アラビア数字(すべて全角)1, 2, ... 10, ... 27 | 28 | ## EPUB(review-epubmaker) 29 | HTML のボディ部が縦書きになるよう、CSS ファイル(review-init コマンドで作成した雛型を利用しているのであれば style.css)にスタイルを追加します。 30 | 31 | ```css 32 | body { 33 | (…既存の設定…) 34 | -webkit-writing-mode: vertical-rl; 35 | -epub-writing-mode: vertical-rl; 36 | writing-mode: tb-rl; 37 | } 38 | ``` 39 | 40 | また、縦書きの書籍は通常、「左開き」(右ページから左ページへ進む)となるので、config.yml の direction パラメータを設定します。 41 | 42 | ```yaml 43 | direction: "rtl" 44 | ``` 45 | 46 | なお、仕様としては正しくても、正しく表示されるかは EPUB リーダーおよび使用フォントに強く依存します(たとえばフォントの選択によっては、句読点が横書き位置のままで崩れた表示になることがあります)。 47 | 48 | ## TeX PDF(review-pdfmaker) 49 | review-pdfmaker のバックエンドとなっている TeX で縦書きを利用するには、ドキュメントクラスファイルを縦書き対応のものに変更する必要があります。config.yml に次のように追加します(`"oneside"` の箇所は必要に応じて変更してください)。 50 | 51 | ```yaml 52 | texdocumentclass: ["utbook", "oneside"] 53 | ``` 54 | 55 | utbook クラスは upLaTeX に合わせた縦書きの紙面デザインを提供します。マクロや追加パッケージが縦書きに対応していない場合、エラーあるいは予想外の結果になることがあります。 56 | 57 | また、表紙・大扉・奥付のように主題とまったく異なる紙面表現の箇所は、TeX のマクロで表現しようとするよりも、Adobe InDesign や Microsoft Word などの別のツールを使って作成した原寸の PDF を用意し、それを貼り付けたほうが思いどおりの結果になるでしょう。`review-custom.sty` に記述する例を以下に示します(各 PDF は `images` フォルダに置いているものとします)。 58 | 59 | ``` 60 | % 縦書きのため各貼り付けPDFは90度回転させる 61 | \def\reviewcoverpagecont{% 表紙 62 | \includefullpagegraphics[angle=90]{images/cover.pdf} 63 | } 64 | 65 | \def\reviewtitlepagecont{% 大扉 66 | \includefullpagegraphics[angle=90]{images/titlepage.pdf} 67 | } 68 | 69 | \def\reviewcolophonpagecont{% 奥付 70 | \includefullpagegraphics[angle=90]{images/colophon.pdf} 71 | } 72 | ``` 73 | -------------------------------------------------------------------------------- /articles/doc/customize_epub.md: -------------------------------------------------------------------------------- 1 | # Supporting local rules of EPUB files 2 | 3 | EPUB files that generated by Re:VIEW (review-epubmaker) should be valid in eubcheck in IDPF. 4 | 5 | But some e-book stores have their own rules, so they reject EPUB files by Re:VIEW. To pass their rules, you can customize OPF file with config.yml. 6 | 7 | ## EBPAJ EPUB 3 File Creation Guide 8 | 9 | * http://ebpaj.jp/counsel/guide 10 | 11 | EBPAJ, the Electronic Book Publishers Association of Japan, releases the guide for publishers to create EPUB files that make nothing of trouble in major EPUB readers. 12 | 13 | To pass their guide, you can add some settings into config.yml: 14 | 15 | ```yaml 16 | opf_prefix: {ebpaj: "http://www.ebpaj.jp/"} 17 | opf_meta: {"ebpaj:guide-version": "1.1.3"} 18 | ``` 19 | 20 | With this settings, Re:VIEW generates OPF files with epbaj attributes: 21 | 22 | ```xml 23 | 24 | ... 25 | 1.1.3 26 | ``` 27 | 28 | But EPUB files that Re:VIEW generates are not the same of name and structure to EBPAJ guide. 29 | 30 | 31 | ## iBookStore 32 | 33 | Without special setting, iBooks has a margin between right page and left page in double-page spread. 34 | 35 | To remove it, you can add some settings in config.yml. 36 | 37 | ```yaml 38 | opf_prefix: {ibooks: "http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/"} 39 | opf_meta: {"ibooks:binding": "false"} 40 | ``` 41 | 42 | If you have already some settings, merge them: 43 | 44 | ```yaml 45 | opf_prefix: {ebpaj: "http://www.ebpaj.jp/", ibooks: "http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/"} 46 | opf_meta: {"ebpaj:guide-version": "1.1.3", "ibooks:binding": "false"} 47 | ``` 48 | 49 | ## Amazon Kindle 50 | 51 | For Kindle, you need to convert EPUB to mobi format using KindleGen, which Amazon distributes. 52 | 53 | - https://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211 54 | 55 | After installation, you can convert EPUB with `kindlegen EPUB file`. 56 | 57 | KindleGen is also included in Kindle Previewer. 58 | 59 | - https://kdp.amazon.co.jp/ja_JP/help/topic/G202131170 60 | 61 | Note: if there is only a "logical" table of contents, KindleGen reports a strange error. To include "physical" table of contents, set config.yml as follows. 62 | 63 | ```yaml 64 | epubmaker: 65 | toc: true 66 | ``` 67 | 68 | You may be warned about some CSS can't be handled in Kindle. "Amazon Kindle Publishing Guidelines" describes in detail the usable characters, restrictions on hyperlinks to the outside, usage of colors, image size, and so on. 69 | 70 | - http://kindlegen.s3.amazonaws.com/AmazonKindlePublishingGuidelines_JP.pdf 71 | -------------------------------------------------------------------------------- /articles/style.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | body { 3 | font-family: "Helvetica Neue", Helvetica, Arial, Meiryo, "メイリオ", sans-serif; 4 | font-size: 16px; 5 | line-height: 1.5; } 6 | 7 | h2 { 8 | border-bottom: 1px solid #ccc; } 9 | 10 | h1, h2, h3 { 11 | margin-top: 28px; 12 | margin-bottom: 14px; } 13 | 14 | h4, h5, h6 { 15 | margin-top: 14px; 16 | margin-bottom: 14px; } 17 | h4:before, h5:before, h6:before { 18 | content: "■"; } 19 | 20 | p { 21 | margin-bottom: 12px; } 22 | 23 | dd { 24 | margin-left: 3em; } 25 | 26 | div.column { 27 | border: solid 3px; 28 | border-radius: 10px; 29 | padding-left: 1em; 30 | padding-right: 1em; 31 | margin-top: 12px; 32 | margin-bottom: 12px; } 33 | div.column h1, div.column h2, div.column h3 { 34 | margin-top: 14px; } 35 | 36 | div.lead { 37 | font-size: 16px; 38 | margin-left: 3em; } 39 | 40 | p.flushright { 41 | text-align: right; } 42 | 43 | .noteref { 44 | vertical-align: super; 45 | font-size: smaller; } 46 | 47 | p.footnote { 48 | font-size: 0.8em; } 49 | 50 | .main-content { 51 | display: flex; 52 | flex-direction: column; } 53 | 54 | div.footnote { 55 | order: 1; } 56 | 57 | .image, .table, .caption-code, .cmd-code { 58 | margin-bottom: 12px; } 59 | 60 | .image .caption, .table .caption { 61 | text-align: center; } 62 | 63 | .image .caption { 64 | margin-top: 0; } 65 | .image .caption:before { 66 | content: "▲"; 67 | color: lightgray; } 68 | 69 | .caption-code .caption, .table .caption { 70 | margin-bottom: 0; } 71 | .caption-code .caption:before, .table .caption:before { 72 | content: "▼"; 73 | color: lightgray; } 74 | 75 | .image img { 76 | display: block; 77 | max-width: 100%; 78 | height: auto; 79 | margin-left: auto; 80 | margin-right: auto; } 81 | 82 | .tb-header { 83 | background-image: url(images/html_header.jpg); 84 | background-size: cover; 85 | height: 20vw; 86 | background-color: #64C1D7; 87 | color: white; 88 | text-indent: 150%; 89 | overflow: hidden; 90 | white-space: nowrap; } 91 | 92 | .tb-nav-link { 93 | margin-top: 1em; 94 | margin-bottom: 1em; } 95 | .tb-nav-link a.prev:before { 96 | content: "<<"; } 97 | .tb-nav-link a.next:after { 98 | content: ">>"; } 99 | 100 | .tb-footer { 101 | margin-top: 16px; 102 | padding-top: 16px; 103 | padding-bottom: 16px; 104 | color: white; 105 | background-color: #424242; } 106 | .tb-footer a { 107 | color: #9e9e9e; } 108 | .tb-footer p { 109 | margin-right: 10px; } 110 | 111 | .tb-footer-links li:nth-child(n+2)::before { 112 | color: #9e9e9e; 113 | content: "/"; 114 | margin-right: 16px; } 115 | -------------------------------------------------------------------------------- /articles/webroot/style.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | body { 3 | font-family: "Helvetica Neue", Helvetica, Arial, Meiryo, "メイリオ", sans-serif; 4 | font-size: 16px; 5 | line-height: 1.5; } 6 | 7 | h2 { 8 | border-bottom: 1px solid #ccc; } 9 | 10 | h1, h2, h3 { 11 | margin-top: 28px; 12 | margin-bottom: 14px; } 13 | 14 | h4, h5, h6 { 15 | margin-top: 14px; 16 | margin-bottom: 14px; } 17 | h4:before, h5:before, h6:before { 18 | content: "■"; } 19 | 20 | p { 21 | margin-bottom: 12px; } 22 | 23 | dd { 24 | margin-left: 3em; } 25 | 26 | div.column { 27 | border: solid 3px; 28 | border-radius: 10px; 29 | padding-left: 1em; 30 | padding-right: 1em; 31 | margin-top: 12px; 32 | margin-bottom: 12px; } 33 | div.column h1, div.column h2, div.column h3 { 34 | margin-top: 14px; } 35 | 36 | div.lead { 37 | font-size: 16px; 38 | margin-left: 3em; } 39 | 40 | p.flushright { 41 | text-align: right; } 42 | 43 | .noteref { 44 | vertical-align: super; 45 | font-size: smaller; } 46 | 47 | p.footnote { 48 | font-size: 0.8em; } 49 | 50 | .main-content { 51 | display: flex; 52 | flex-direction: column; } 53 | 54 | div.footnote { 55 | order: 1; } 56 | 57 | .image, .table, .caption-code, .cmd-code { 58 | margin-bottom: 12px; } 59 | 60 | .image .caption, .table .caption { 61 | text-align: center; } 62 | 63 | .image .caption { 64 | margin-top: 0; } 65 | .image .caption:before { 66 | content: "▲"; 67 | color: lightgray; } 68 | 69 | .caption-code .caption, .table .caption { 70 | margin-bottom: 0; } 71 | .caption-code .caption:before, .table .caption:before { 72 | content: "▼"; 73 | color: lightgray; } 74 | 75 | .image img { 76 | display: block; 77 | max-width: 100%; 78 | height: auto; 79 | margin-left: auto; 80 | margin-right: auto; } 81 | 82 | .tb-header { 83 | background-image: url(images/html_header.jpg); 84 | background-size: cover; 85 | height: 20vw; 86 | background-color: #64C1D7; 87 | color: white; 88 | text-indent: 150%; 89 | overflow: hidden; 90 | white-space: nowrap; } 91 | 92 | .tb-nav-link { 93 | margin-top: 1em; 94 | margin-bottom: 1em; } 95 | .tb-nav-link a.prev:before { 96 | content: "<<"; } 97 | .tb-nav-link a.next:after { 98 | content: ">>"; } 99 | 100 | .tb-footer { 101 | margin-top: 16px; 102 | padding-top: 16px; 103 | padding-bottom: 16px; 104 | color: white; 105 | background-color: #424242; } 106 | .tb-footer a { 107 | color: #9e9e9e; } 108 | .tb-footer p { 109 | margin-right: 10px; } 110 | 111 | .tb-footer-links li:nth-child(n+2)::before { 112 | color: #9e9e9e; 113 | content: "/"; 114 | margin-right: 16px; } 115 | -------------------------------------------------------------------------------- /articles/lib/tasks/z01_pandoc2review.rake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Kenshi Muto 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | require 'fileutils' 22 | require 'yaml' 23 | 24 | def make_mdre(ch, p2r, path) 25 | if File.exist?(ch) # re file 26 | FileUtils.cp(ch, path) 27 | elsif File.exist?(ch.sub(/\.re\Z/, '.md')) # md file 28 | system("#{p2r} #{ch.sub(/\.re\Z/, '.md')} > #{path}/#{ch}") 29 | end 30 | end 31 | 32 | desc 'run pandoc2review' 33 | task :pandoc2review do 34 | config = YAML.load_file('config.yml') 35 | if config['contentdir'] == '_refiles' 36 | path = '_refiles' 37 | p2r = 'pandoc2review' 38 | 39 | unless File.exist?(path) 40 | Dir.mkdir(path) 41 | File.write("#{path}/THIS_FOLDER_IS_TEMPORARY", '') 42 | end 43 | 44 | catalog = YAML.load_file('catalog.yml') 45 | %w(PREDEF CHAPS APPENDIX POSTDEF).each do |block| 46 | if catalog[block].kind_of?(Array) 47 | catalog[block].each do |ch| 48 | if ch.kind_of?(Hash) # Parts 49 | ch.each_pair do |k, v| 50 | make_mdre(k, p2r, path) 51 | # Chapters 52 | v.each {|subch| make_mdre(subch, p2r, path) } 53 | end 54 | elsif ch.kind_of?(String) # Chapters 55 | make_mdre(ch, p2r, path) 56 | end 57 | end 58 | end 59 | end 60 | end 61 | end 62 | 63 | CLEAN.include('_refiles') 64 | Rake::Task[BOOK_PDF].enhance([:pandoc2review]) 65 | Rake::Task[BOOK_EPUB].enhance([:pandoc2review]) 66 | Rake::Task[WEBROOT].enhance([:pandoc2review]) 67 | Rake::Task[TEXTROOT].enhance([:pandoc2review]) 68 | Rake::Task[TOPROOT].enhance([:pandoc2review]) 69 | Rake::Task[IDGXMLROOT].enhance([:pandoc2review]) 70 | -------------------------------------------------------------------------------- /redpen-conf-ja.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 37 | 38 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /articles/style.scss: -------------------------------------------------------------------------------- 1 | // Variables 2 | $main-color: #64C1D7; 3 | $footer-link-color: #9e9e9e; 4 | $font-size: 16px; 5 | $paragraph-margin-bottom: $font-size * 0.75; 6 | 7 | // デフォルトの装飾を上書く 8 | body { 9 | font-family: "Helvetica Neue", Helvetica, Arial, Meiryo, "メイリオ", sans-serif; 10 | font-size: $font-size; 11 | line-height: 24px / $font-size; 12 | } 13 | h2 { 14 | border-bottom: 1px solid #ccc; 15 | } 16 | h1, h2, h3 { 17 | margin-top: $font-size * 0.875 * 2; 18 | margin-bottom: $font-size * 0.875; 19 | } 20 | h4, h5, h6 { 21 | margin-top: $font-size * 0.875; 22 | margin-bottom: $font-size * 0.875; 23 | &:before { 24 | content: "■"; 25 | } 26 | } 27 | p { 28 | margin-bottom: $paragraph-margin-bottom; 29 | } 30 | dd { 31 | margin-left: 3em; 32 | } 33 | 34 | // コラム 35 | div.column { 36 | border: solid 3px; 37 | border-radius: 10px; 38 | padding-left: 1em; 39 | padding-right: 1em; 40 | margin-top: $paragraph-margin-bottom; 41 | margin-bottom: $paragraph-margin-bottom; 42 | h1, h2, h3 { 43 | margin-top: $font-size * 0.875; 44 | } 45 | } 46 | 47 | // リード文 48 | div.lead { 49 | font-size: $font-size; 50 | margin-left: 3em; 51 | } 52 | 53 | // 右寄せ文 54 | p.flushright { 55 | text-align: right; 56 | } 57 | 58 | // footnote 59 | .noteref { 60 | vertical-align: super; 61 | font-size: smaller; 62 | } 63 | p.footnote { 64 | font-size: 0.8em; 65 | } 66 | // footnoteは最後に持ってくる 67 | .main-content { 68 | display: flex; 69 | flex-direction: column; 70 | } 71 | div.footnote { 72 | order: 1; 73 | } 74 | 75 | // 画像やリストなどのキャプション系 76 | .image, .table, .caption-code, .cmd-code { 77 | margin-bottom: $paragraph-margin-bottom; 78 | } 79 | .image, .table { // キャプションを中央寄せするもの 80 | .caption { 81 | text-align: center; 82 | } 83 | } 84 | .image { // キャプションに▲を付けるもの 85 | .caption { 86 | margin-top: 0; 87 | &:before { 88 | content: "▲"; 89 | color: lightgray; 90 | } 91 | } 92 | } 93 | .caption-code, .table { // キャプションに▼を付けるもの 94 | .caption { 95 | margin-bottom: 0; 96 | &:before { 97 | content: "▼"; 98 | color: lightgray; 99 | } 100 | } 101 | } 102 | .image { 103 | img { // 画像は中央余生にしとく 104 | display: block; 105 | max-width: 100%; 106 | height: auto; 107 | margin-left: auto;; 108 | margin-right: auto; 109 | } 110 | } 111 | 112 | // ヘッダ 113 | .tb-header { 114 | background-image: url(images/html_header.jpg); 115 | background-size: cover; 116 | height: 20vw; 117 | background-color: $main-color; 118 | color: white; 119 | 120 | // テキストは隠す 121 | text-indent: 150%; 122 | overflow: hidden; 123 | white-space: nowrap; 124 | } 125 | 126 | // メニューまわり 127 | .tb-nav-link { 128 | margin-top: 1em; 129 | margin-bottom: 1em; 130 | a.prev:before { 131 | content: "<<"; 132 | } 133 | a.next:after { 134 | content: ">>"; 135 | } 136 | } 137 | 138 | // フッタ 139 | .tb-footer { 140 | margin-top: 16px; 141 | padding-top: 16px; 142 | padding-bottom: 16px; 143 | color: white; 144 | background-color: #424242; 145 | a { 146 | color: $footer-link-color; 147 | } 148 | p { 149 | margin-right: 10px; 150 | } 151 | } 152 | .tb-footer-links { 153 | li:nth-child(n+2)::before { 154 | color: $footer-link-color; 155 | content: "/"; 156 | margin-right: 16px; 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /articles/doc/makeindex.ja.md: -------------------------------------------------------------------------------- 1 | # 索引の使い方 2 | インラインタグ `@` および `@` を用いて、索引単語を埋め込むことができます。索引を整列するにはその索引単語の「読み」が必要ですが、LaTeX ビルダにおいては、用意した辞書や形態素解析を使い、読み順に整列して紙面化します。 3 | 4 | ## 注意 5 | * LaTeX の mendex コマンドの実装に依存しているため、 現時点では英語または日本語以外の挙動は不明です。 6 | * 形態素解析は、外部ソフトウェアの MeCab (http://taku910.github.io/mecab/) 、その辞書である IPA 辞書、MeCab の Ruby バインドである mecab に依存しています。 7 | * LaTeX ビルダ以外のビルダでは、埋め込んだ索引を利用する手法を提供していません。後述のヒントを参照してください。 8 | * LaTeX ビルダでの索引生成機能は、デフォルトで無効にしています。設定 YAML ファイルで明示的に有効にする必要があります。 9 | 10 | ## MeCab のセットアップ 11 | 形態素解析による自動読みを使用する場合、MeCab (http://taku910.github.io/mecab/) およびその辞書、Ruby バインドライブラリの mecab をインストールしておく必要があります。 12 | 13 | Debian GNU/Linux あるいは Ubuntu の環境では、次のようにパッケージをインストールします。 14 | 15 | ``` 16 | apt install mecab mecab-ipadic-utf8 ruby-mecab 17 | ``` 18 | 19 | MeCab 標準の辞書としては IPA 辞書と Juman 辞書がありますが、本機能の自動読みのためには「-Oyomi」オプションがサポートされている必要があり、これに対応しているのは IPA 辞書のみです。 20 | 21 | ## 設定 22 | review-pdfmaker での索引作成を有効にするため、config.yml (別の設定ファイルを使う場合はその YAML ファイル) に、次のように追加します。 23 | 24 | ``` 25 | pdfmaker: 26 | makeindex: true 27 | ``` 28 | 29 | re ファイル内に、`@` または `@` インラインタグを使って索引を埋め込みます。`@` は、指定の文字列をそのまま紙面に出力するとともに索引とします。`@` (hidden index) は、指定の文字列を索引とするのみで、紙面には出力しません。`@` の場合は文字列内を `<<>>` で区切り、`親索引語<<>>子索引語`、`親索引語<<>>子索引語<<>>孫索引語` とレベル分けした索引を指定できます。 30 | 31 | ``` 32 | @{表示もする索引}です 33 | ↓ 34 | 表示もする索引です 35 | 36 | [索引] 37 | ひ 38 | 表示もする索引....1 39 | ``` 40 | 41 | ``` 42 | @{表示しない索引}です@{親<<>>子} 43 | ↓ 44 | です 45 | 46 | [索引] 47 | お 48 | 親 49 | 子................1 50 | 51 | 52 | ひ 53 | 表示しない索引....1 54 | ``` 55 | 56 | ## 読み辞書 57 | 形態素解析は万能ではなく、特に短い単語は音読み・訓読みの違いで期待と異なる結果になりやすく、また辞書に載っていない専門的な単語は読みを解釈できずにおかしな結果になります。 58 | 59 | 内部で使用している mendex プログラムに与える読み辞書を用意すれば、まずその辞書でのマッチングを試み、マッチングしなかったときに形態素解析を試みる、という手順をとることができます。また、MeCab を利用できない環境でも、すべての索引単語を解決できる読み辞書を用意すれば、索引機能を利用できます。 60 | 61 | 辞書は次のように熟語と読みのペアをタブまたはスペースで区切ったテキストファイルとして作成します。 62 | 63 | ``` 64 | 漢字 かんじ 65 | 読み よみ 66 | α あるふぁ 67 | ``` 68 | 69 | このファイルを config.yml 設定ファイルで指定します (以下では my.dic を指定)。 70 | 71 | ``` 72 | pdfmaker: 73 | makeindex: true 74 | makeindex_dic: my.dic 75 | ``` 76 | 77 | なお、mendex のアルゴリズム上、辞書や形態素解析の適用は常にうまくいくとは限りません。たとえば「表 (ひょう、おもて)」のように 2 通りの読み方があるような語を使い分けたいというときには、review-pdfmaker のフック機能を使い、LaTeX のソースファイルに変換したところで LaTeX の索引命令に読みを明示する (たとえば `\index{おもて@表}`) といった対処が必要になるでしょう。LaTeX の索引命令の詳細については、mendex コマンドのオンラインマニュアルを参照してください。 78 | 79 | ## カスタマイズ 80 | `pdfmaker:` 以下に記述可能な YAML 設定を以下にまとめます。 81 | 82 | * `makeindex`: `true` で索引を作成 (デフォルト: `null`=作成しない) 83 | * `makeindex_command`: 索引作成の支援コマンド (デフォルト: `mendex`) 84 | * `makeindex_options`: 支援コマンドのオプション (デフォルト: `-f -r -I utf8`) 85 | * `makeindex_sty`: 支援コマンドで使うスタイルファイル (デフォルト: `null`) 86 | * `makeindex_dic`: 支援コマンドで使う読み辞書ファイル (デフォルト: `null`) 87 | * `makeindex_mecab`: MeCab による形態素解析を試みる (デフォルト: `true`=使用する) 88 | * `makeindex_mecab_opts`: MeCab で読みを取得するオプション (デフォルト: `-Oyomi`) 89 | 90 | たとえば索引ページの見た目の表現は mendex コマンドのデフォルトのものが使われますが、設定をファイルで用意し、`makeindex_sty` にそのファイルを指定すれば変更できます。設定については mendex コマンドのオンラインマニュアルを参照してください。 91 | 92 | ## ヒント 93 | 「注意」で述べたとおり、LaTeX ビルダ以外のビルダでそれを活用する方法は提供していません。というのも、ほかのビルダでは、索引を読み順に並べ替えたり、それを表現したりといった方法についての一般的な解が存在しないからです。 94 | 95 | EPUB (HTML ビルダ) では `` のコメントで、IDGXML ビルダでは `` の XML 要素で、それぞれ索引は埋め込まれます。たとえばこれらを拾い出して、独自の辞書読み・整列ツール (LaTeX の mendex コマンドを流用するなど) を用意する方法が考えられるでしょう。 96 | -------------------------------------------------------------------------------- /articles/doc/preproc.ja.md: -------------------------------------------------------------------------------- 1 | # review-preproc ユーザガイド 2 | 3 | Re:VIEWではソースコードなどを本文中に埋め込むことができます。 4 | 5 | ## `#@mapfile` 6 | 7 | 以下は`scripts/hello.rb`のソースを本文内に埋め込んでいます。 8 | 9 | ```review 10 | //list[hello.rb][hello.rb]{ 11 | #@mapfile(scripts/hello.rb) 12 | #!/usr/bin/env ruby 13 | 14 | class Hello 15 | def hello(name) 16 | print "hello, #{name}!\n" 17 | end 18 | end 19 | 20 | if __FILE__ == $0 21 | Hello.new.hello("world") 22 | end 23 | #@end 24 | //} 25 | ``` 26 | 「`#@mapfile(ファイル名)`」から「`#@end`」は、指定したファイル名のファイル全体を本文中に埋め込むための記法です。埋め込む際には、`review-preproc`コマンドを実行します。 27 | 28 | まず、以下のように、引用したい部分に「`#@mapfile()`」と「`#@end`」だけを書きます。ここでは`//list`ブロック内にこの2行だけを記述しています。 29 | 30 | ```review 31 | //list[hello.rb.1][hello.re]{ 32 | #@mapfile(scripts/hello.rb) 33 | #@end 34 | //} 35 | ``` 36 | このソースに対して、`review-preproc`コマンドを実行します。すると、変換結果の*.reファイルを標準出力に出力します。 37 | 38 | ```shell-session 39 | $ review-preproc hello.re 40 | ``` 41 | `--replace`オプションをつければ、ファイルそのものを置き換えるようになります。 42 | 43 | ```shell-session 44 | $ review-preproc --replace hello.re 45 | ``` 46 | 47 | なお、rakeを使ってビルドしている場合、Rakefileに以下のような記述を追加すると、このコマンドを実行するtaskが定義されます。 48 | 49 | ```rake 50 | desc 'preproc all' 51 | task :preproc do 52 | Dir.glob("*.re").each do |file| 53 | sh "review-preproc --replace #{file}" 54 | end 55 | end 56 | ``` 57 | 58 | 以下のように実行すれば、コマンドが実行されます。 59 | 60 | ```shell-session 61 | $ rake preproc 62 | ``` 63 | 64 | ## `#@maprange` 65 | 66 | 対象ファイルの一部だけ抜粋することもできます。こちらは「`#@maprange`」という記法を使います。 67 | 68 | 対象ファイルの抜粋したい部分の前後に、「`#@range_begin(ID)`」と「`#@range_end`」という記法を埋め込んでおきます。`#@range_begin`の引数には、その断片を抽出する際に使用するIDを指定します。以下の例では「sample」というIDにしています。 69 | 70 | ```ruby 71 | #!/usr/bin/env ruby 72 | 73 | class Hello 74 | #@range_begin(sample) 75 | def hello(name) 76 | print "hello, #{name}!\n" 77 | end 78 | #@range_end(sample) 79 | end 80 | 81 | if __FILE__ == $0 82 | Hello.new.hello("world") 83 | end 84 | ``` 85 | *.reファイルのほうには、「`#@mapfile(ファイル名)`」ではなく「`#@maprange(ファイル名,ID)`」を記述します。 86 | 87 | ```review 88 | //list[range.rb][range.rb(抜粋)]{ 89 | #@maprange(scripts/range.rb,sample) 90 | #@end 91 | //} 92 | ``` 93 | 94 | あとは、先ほど同様、`review-preproc`コマンドか`rake preproc`コマンドを実行します。そうすると、`scripts/range.rb`の一部が抽出されて埋め込まれます。 95 | 96 | ```review 97 | //list[range.rb][range.rb(抜粋)]{ 98 | #@maprange(scripts/range.rb,sample) 99 | def hello(name) 100 | print "hello, #{name}!\n" 101 | end 102 | #@end 103 | //} 104 | ``` 105 | 106 | ## `#@@maprange` 107 | 108 | もっとも、Ruby以外では「`#@range_begin`」などがコメントと解釈されないこともあります。そのような場合、その言語のコメントの中に「`#@@range_begin`」と「`#@@range_end`」とを記述します。 109 | 110 | Cのソースを例にします。対象となるrange.cは以下です。 111 | 112 | ```c 113 | #include 114 | 115 | /* #@@range_begin(sample) */ 116 | void 117 | put_hello(char *name) 118 | { 119 | printf("hello, %s!\n", name); 120 | } 121 | /* #@@range_end(sample) */ 122 | 123 | int main() 124 | { 125 | put_hello("world"); 126 | } 127 | ``` 128 | 129 | put_hello関数の定義の前後で「`#@@range_begin`」と「`#@@range_end`」が使われています。 130 | 131 | これに対し、*.reファイルでは`#@maprange(scripts/range.c,sample)`と`#@end`を記述します。 132 | 133 | ``` 134 | //list[range.c][range.c(抜粋)]{ 135 | #@maprange(scripts/range.c,sample) 136 | #@end 137 | //} 138 | ``` 139 | 140 | 変換した結果、以下のようになります。 141 | 142 | ``` 143 | //list[range.c][range.c(抜粋)]{ 144 | #@maprange(scripts/range.c,sample) 145 | void 146 | put_hello(char *name) 147 | { 148 | printf("hello, %s!\n", name); 149 | } 150 | #@end 151 | //} 152 | ``` 153 | このようにすると、Cなどの言語のファイルに対しても、ソースの一部を抽出して埋め込むことができます。 154 | -------------------------------------------------------------------------------- /articles/doc/format_idg.ja.md: -------------------------------------------------------------------------------- 1 | # Re:VIEW フォーマット InDesign XML 形式拡張 2 | 3 | Re:VIEW フォーマットから、Adobe 社の DTP ソフトウェア「InDesign」で読み込んで利用しやすい XML 形式に変換できます (通常の XML とほぼ同じですが、文書構造ではなく見た目を指向した形態になっています)。実際には出力された XML を InDesign のスタイルに割り当てるフィルタをさらに作成・適用する必要があります。 4 | 5 | 基本のフォーマットのほかにいくつかの拡張命令を追加しています。 6 | 7 | このドキュメントは、Re:VIEW 3.0 に基づいています。 8 | 9 | ## 追加したブロック 10 | これらのブロックは基本的に特定の書籍向けのものであり、将来廃棄する可能性があります。 11 | 12 | * `//insn[タイトル]{ 〜 //}` または `//box[タイトル]{ 〜 //}` : 書式 13 | * `//planning{ 〜 //}` または `//planning[タイトル]{ 〜 //}` : プランニング 14 | * `//best{ 〜 //}` または `//best[タイトル]{ 〜 //}` : ベストプラクティス 15 | * `//security{ 〜 //}` または `//security[タイトル]{ 〜 //}` : セキュリティ 16 | * `//expert{ 〜 //}` : エキスパートに訊く 17 | * `//point{ 〜 //}` または `//point[タイトル]{ 〜 //}` : ワンポイント 18 | * `//shoot{ 〜 //}` または `//shoot[タイトル]{ 〜 //}` : トラブルシューティング 19 | * `//term{ 〜 //}` : 用語解説 20 | * `//link{ 〜 //}` または `//link[タイトル]{ 〜 //}` : 他の章やファイルなどへの参照説明 21 | * `//practice{ 〜 //}` : 練習問題 22 | * `//reference{ 〜 //}` : 参考情報 23 | 24 | ## 相互参照 25 | 26 | `//label[〜]` でラベルを定義し、`@{〜}` で参照します。XML としては `