typub_markdown/render/options.rs
1//! Markdown rendering options.
2//!
3//! Provides configuration options for the Markdown renderer.
4
5use std::collections::BTreeMap;
6use typub_core::MathDelimiters;
7use typub_ir::{AssetId, Url};
8
9use crate::processing::MarkdownProcessingRules;
10
11/// Options for Markdown rendering.
12pub struct MarkdownRenderOptions<'a> {
13 /// Optional mapping from asset id to a resolved URL.
14 /// If provided, this takes precedence over IR asset variants/source.
15 pub asset_urls: Option<&'a BTreeMap<AssetId, Url>>,
16 /// Math delimiter syntax to use for LaTeX math.
17 /// Default is `Dollar` ($...$ and $$...$$).
18 pub math_delimiters: MathDelimiters,
19 /// Whether to use inline HTML (`<img>` tags) for images with dimensions.
20 /// Standard Markdown doesn't support width/height attributes on images.
21 /// When true, images with width/height attrs will be rendered as `<img>` tags.
22 /// When false (default), dimensions are ignored and standard `` syntax is used.
23 pub use_inline_html_for_sized_images: bool,
24 /// Whether lists should be tight (no blank lines between items).
25 /// Default is true. Set to false for loose lists with blank lines.
26 pub tight_lists: bool,
27 /// Markdown post-processing rules.
28 /// Applied after serialization to handle platform-specific editor quirks.
29 pub processing_rules: MarkdownProcessingRules,
30}
31
32impl<'a> Default for MarkdownRenderOptions<'a> {
33 fn default() -> Self {
34 Self {
35 asset_urls: None,
36 math_delimiters: MathDelimiters::Dollar,
37 use_inline_html_for_sized_images: false,
38 tight_lists: true,
39 processing_rules: MarkdownProcessingRules::empty(),
40 }
41 }
42}