コンテンツにスキップ

Rust Core API の状況

前提: Document IR。このページは mdi-core/src/lib.rs にあるものだけを記載します。自動 cargo doc site は Planned です。食い違いがあれば source を正としてください。

  • MDI_SPEC_VERSION: &str = "2.0"
  • MDI_IR_VERSION: &str = "1.0"
  • MDI_STYLESHEET: &strrender_html に埋め込まれる CSS。 stylesheet parity を参照。
  • 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) -> MdiSyntaxDocumentdeprecated 互換 API。

serialize_mdi(source: &str) -> String / serialize_mdi_document(document: &Document) -> String は canonical MDI/Markdown に serialize します。例えば 《《text》》 を `text` に正規化します。

  • render_html / render_html_document → standalone HTML
  • render_text / render_text_document → plain txt
  • render_text_format(source, format: TextFormat, indent_prefix)txttxt-rubynaroukakuyomuaozoranote
  • render_epub / render_epub_documentResult<Vec<u8>, String> EPUB 3
  • render_epub_with_profile / render_epub_document_with_profile → metadata、typography、chapter split、PNG/JPEG cover 付き EPUB 3
  • render_docx / render_docx_documentResult<Vec<u8>, String> DOCX
  • render_docx_with_profile / render_docx_document_with_profile → page geometry、typography、grid、mirror margin、page number 付き DOCX
  • render_pdf(source, options: &PdfOptions) → local Chromium による PDF
  • find_chromium() -> Option<PathBuf> → Chromium の best-effort search
  • 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 を適用します。

current-generation API は ParseOutputParserCapabilitiesDiagnosticSourceSpanDocumentFrontmatterMdiTextBlocksResultMdiSourceSpanTextResolutionMdiSourceSpanTextMatchMdiSourceSpanCoverageMdiSourceSpanRelationMdiSourceSpanResolutionErrorPdfOptionsEpubCoverResolvedExportProfile とその nested profile/Chromium print types です。旧 shape は MdiSyntaxDocumentMdiBlockPagebreakVariantInlineRubyReading です。

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 にまとめられます。

  • 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 であるという 意味ではありません。