Rust Core API の状況
前提: Document IR。このページは mdi-core/src/lib.rs にあるものだけを記載します。自動 cargo doc site は Planned です。食い違いがあれば source を正としてください。
Constants
Section titled “Constants”MDI_SPEC_VERSION: &str = "2.0"MDI_IR_VERSION: &str = "1.0"MDI_STYLESHEET: &str—render_htmlに埋め込まれる CSS。 stylesheet parity を参照。
Parsing
Section titled “Parsing”parse_document(source: &str) -> Document— 完全な一回解析。parse_output(source: &str) -> ParseOutput— versioned envelope。parse_json(source: &str) -> String— FFI が渡る JSON。parse_inlines(source: &str) -> Vec<Inline>— MDI inline 専用。parse_mdi_syntax(source: &str) -> MdiSyntaxDocument— deprecated 互換 API。
Serialization
Section titled “Serialization”serialize_mdi(source: &str) -> String / serialize_mdi_document(document: &Document) -> String は canonical MDI/Markdown に serialize します。例えば 《《text》》 を `text` に正規化します。
Rendering
Section titled “Rendering”render_html/render_html_document→ standalone HTMLrender_text/render_text_document→ plaintxtrender_text_format(source, format: TextFormat, indent_prefix)→txt、txt-ruby、narou、kakuyomu、aozora、noterender_epub/render_epub_document→Result<Vec<u8>, String>EPUB 3render_epub_with_profile/render_epub_document_with_profile→ metadata、typography、chapter split、PNG/JPEG cover 付き EPUB 3render_docx/render_docx_document→Result<Vec<u8>, String>DOCXrender_docx_with_profile/render_docx_document_with_profile→ page geometry、typography、grid、mirror margin、page number 付き DOCXrender_pdf(source, options: &PdfOptions)→ local Chromium による PDFfind_chromium() -> Option<PathBuf>→ Chromium の best-effort search
Publication profile
Section titled “Publication profile”resolve_export_profile/resolve_export_profile_json— canonical profile を検証し、default を補います。page_dimensions/page_size_catalog_json— binding と renderer が共用する 67 種の physical paper catalogue。prepare_chromium_print_profileと JSON/resolved variants — Chromium host 用の styled HTML、mm 単位 geometry、margin、page-number template。apply_pdf_profile/apply_pdf_profile_json— browser を起動せず resolved print CSS を適用します。
Public data types
Section titled “Public data types”current-generation API は ParseOutput、ParserCapabilities、Diagnostic、SourceSpan、Document、Frontmatter、MdiTextBlocksResult、MdiSourceSpanTextResolution、MdiSourceSpanTextMatch、MdiSourceSpanCoverage、MdiSourceSpanRelation、MdiSourceSpanResolutionError、PdfOptions、EpubCover、ResolvedExportProfile とその nested profile/Chromium print types です。旧 shape は MdiSyntaxDocument、MdiBlock、PagebreakVariant、Inline、RubyReading です。
get_mdi_text_blocks(source) は grapheme 単位の canonical text projection を返し、
resolve_mdi_source_span(source, span) は half-open UTF-8 source span を本文と ruby
annotation の range に逆引きします。coverage、relation、boundary、delimiter、
synthetic/unmapped、round-trip の制約は Rust binding を参照してください。
複数 span は resolve_mdi_source_spans(source, spans) で一度の parse/projection にまとめられます。
Not yet implemented
Section titled “Not yet implemented”parse_outputと別個の validation API はありません。serialize_mdiと別個の normalize API はありません。
DOCX は ruby、tate-chu-yoko、emphasis、kern、page geometry などを native または portable な OOXML で出力します。ただし Word-compatible reader ごとに和文の行組みは異なるため、browser と pixel-identical であるという 意味ではありません。