コンテンツにスキップ

Export profile

前提: Getting Started

export profile は page、font、margin、indent、page number という表示を決めます。MDI syntax や document の意味は変えません。package は @illusions-lab/mdi-export-profile です。resolveExportProfile は誤った layout data を黙って受け入れず、field 名を含む Error を返します。

{
"layout": { "system": "word" },
"metadata": { "title": "The Last Station", "author": "A Writer", "publisher": "Example Press", "identifier": "isbn:9780000000000" },
"typesetting": { "writingMode": "horizontal", "fontFamily": "Noto Serif JP", "fontSize": 10.5, "lineSpacing": 1.4, "textIndentEm": 1 },
"pagination": {
"pageSize": "A4", "landscape": false, "gridMode": "typographic",
"margins": { "top": 25.4, "bottom": 25.4, "left": 25.4, "right": 25.4 },
"pageNumbers": { "enabled": true, "format": "simple", "position": "bottom-center" }
},
"epub": { "chapterSplitLevel": "h1", "coverPath": "cover.png" },
"text": { "fullwidthSpaceIndent": true, "indentCount": 1 }
}

resolveExportProfile({}) は internal の default resolution 用ですが、CLI の --config と設定付き @illusions-lab/mdi export では layout.system が必須です。"japanese-publisher"(strict な和文 book)か "word"(flowing Word page)を一つ選びます。二つの contract は混ぜません。

Field型 / default条件
layout.system"japanese-publisher" | "word"設定付き export では必須。layout 全体を選ぶ。
layout.marginMode / bindingSide / gutterpublisher: mirror / direction-dependent / 0 mmword は single margin、gutter なし。
metadata.*optional string指定時は string。
typesetting.writingMode"horizontal""horizontal" | "vertical"
fontFamily / fontSize / lineSpacingMincho stack / system default / optionallineSpacing は typographic のみ。
pagination.pageSizepublisher horizontal: Shirokuban; vertical: A4 landscape; word: A4PAGE_SIZES の key。
charactersPerLine / linesPerPagepublisher horizontal: 27×26; vertical: 40×3010–400。word の count は情報用で、page contract ではない。
gridModepublisher: strict; word: typographicword は strict を reject。strict は line spacing を reject。
marginspublisher: 16.5/18/18/15.5 mm; word: 四辺 25.4 mmprintable area を残す必要がある。
pageNumbersenabled / simple / bottom-centerformat は simple / dash / fraction、位置は 6 種。
epub.chapterSplitLevel / coverPathh1 / optionalh1/h2/h3/none。CLI cover は PNG/JPEG。
text.fullwidthSpaceIndent / indentCountfalse / 1boolean / 1–4。

japanese-publisher の default は mirror spread です。横書きは 10 pt Mincho の Shirokuban、左綴じ 27 字 × 26 行、縦書きは A4 landscape の小説原稿、右綴じ 40 字 × 30 行の strict grid になります。word の default は A4、四辺 25.4 mm、mirror なしの flowing typographic layout です。

Terminal window
mdi build novel.mdi --to pdf --config novel.export.json -o novel.pdf
mdi build novel.mdi --to docx --config novel.export.json
mdi build novel.mdi --to epub --config novel.export.json
mdi build novel.mdi --to txt-ruby --config novel.export.json
import { parseExportProfileJson, resolveExportProfile } from "@illusions-lab/mdi-export-profile";
const profile = parseExportProfileJson(await readFile("novel.export.json", "utf8"));
const resolved = resolveExportProfile(profile);

resolvePrintProfile(profile, sourceWritingMode) は PDF/print 用の wrapper です。front matter の writing mode を default とし、明示した profile を優先します。paper orientation を vertical のために勝手に landscape へ変更しません。

設定PDFTXT / txt-rubyEPUB / DOCX
page geometry、font、page numberYesDOCX: Yes。EPUB は typography を使うが reflowable。
metadata / writing modeYesEPUB / DOCX: Yes。
full-width-space indentYesYes(text.indentCount で 1–4)EPUB / DOCX: Yes。
cover image、chapter splitEPUB: Yes。

adapter は Rust が parse した IR を package し、layout policy は MDI parser の外に保ちます。EPUB は reflowable なので固定の physical page を約束しません。