此工具針對「檔案」校正中文文案的排版,統一中文文案與排版格式皆參考中文文案排版指北。
此工具是基於 NauxLiu/auto-correct 做出來的「自動中文排版工具」。
** 此工具只在 Command-Line 模式中運行 **
- PHP 5.6+
透過 Composer:
$ composer require wadehuang1993/auto-correct-chinese-typesetting --prefer-stable dev-master
或將 AutoCorrectChineseTypesetting Clone 下來即可。
AutoCorrectChineseTypesetting 必須在 PHP-CLI 模式下進行:
- 將要進行排版的檔案放到 AutoCorrectChineseTypesetting 目錄下。
- 使用 PHP-CLI 執行 AutoCorrect.php 校正中文文案排版。
- AutoCorrect.php 會自動將校正完成的檔案輸出至 Outputs 目錄內。
在 Command-Line 模式中:
cd path/to/AutoCorrectChineseTypesetting
php AutoCorrect.php -i InputFile -o OutputFile
若 OutputFile 沒定義的話,預設輸出的檔案名稱會與輸入檔案名稱相同。
-i 要做排版的檔案名稱。
-o 輸出的檔案名稱(可選)。
-a 新增校正辭彙庫(可選,可多次新增)。
-h 查看使用說明。
-a
參數提供了新增辭彙庫的功能:
- 將您要新增的辭彙庫(xxx.php)放置於 dictionary 目錄下。
- 執行 AutoCorrect.php 並使用
-a
參數加載辭彙庫。 - 可多次使用 -a 參數,加載多個辭彙庫。
辭彙庫必須為 *.php
檔案,其內容為:
<?php
return [
# '校正前的字詞' => '校正後的字詞',
/**
* ...將您的新詞彙加入於此。
*/
'docker' => 'Docker',
'deploy' => 'Deploy',
'zf1' => 'ZendFramework 1',
'zf2' => 'ZendFramework 2',
];
cd path/to/AutoCorrectChineseTypesetting
php AutoCorrect.php -i InputFile -a dictionary/AAA.php -a dictionary/BBB.php
此版本目前只有測試過 txt 檔案可正常排版。