この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
はじめに
Re:VIEWによる文書作成環境を整え、文書校正支援用ツール導入にも着手してみました。textlint
とprh
の組み合わせにたどり着きましたが、これまた導入でとにかく嵌りました。
動作するまでには至れたため、設定手順をまとめてみました。
インストール
関連モジュールも合わせてインストールしていきます。
npm init # 全部EnterでもOK
npm i -g textlint
npm i -g textlint-rule-preset-ja-technical-writing
npm i -g textlint-rule-preset-ja-spacing
npm i -g textlint-rule-preset-japanese
npm i -g textlint-rule-prh
npm i -g textlint-plugin-review
今回インストール後のpackage.json
は以下のようになりました。
{
"name": "sample",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"doc": "doc",
"lib": "lib"
},
"dependencies": {
"textlint": "^11.7.6",
"textlint-rule-preset-ja-technical-writing": "^4.0.0",
"textlint-rule-preset-japanese": "^5.0.0",
"textlint-rule-prh": "^5.3.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
textlintの設定を追加
.textlintrc
に追加します。
% touch .textlintrc
% vim .textlintrc
{
"rules": {
"preset-japanese": true,
"preset-ja-technical-writing": true,
"preset-ja-spacing": true,
"prh": {
"rulePaths": ["./prh.yml"]
}
},
"plugins": [
"review"
]
}
prh init
にてprh.yml
を作成します。
% npx prh init
create prh.yml
see prh/rules collection https://github.com/prh/rules
生成されたprh.yaml
には辞書ファイル等のインポート指定がコメントアウトにて含まれています。review
に関連する設定を有効にしておきたい場合は事前にgitリポジトリ化しておくと楽です。
git submodule add https://github.com/prh/rules.git prh-rules
imports:
# - ./prh-rules/media/techbooster.yml
# - ./prh-rules/files/markdown.yml
- # - ./prh-rules/files/review.yml
+ - ./prh-rules/files/review.yml
reviewファイルの校正
実際の校正は以下のコマンドになります。aleのreview用linter指定はredpenのみのため取り敢えずの対応です。
% textlint sample.re
あとがき
aleのreview用linter指定にtextlintがない点については、forkしての対処が必要になりそうです。
とりあえずの校正環境は揃ったため、次はPDF化までの手順を検証してみようと思います。