pub struct ConversionOptions {Show 43 fields
pub heading_style: HeadingStyle,
pub list_indent_type: ListIndentType,
pub list_indent_width: usize,
pub bullets: String,
pub strong_em_symbol: char,
pub escape_asterisks: bool,
pub escape_underscores: bool,
pub escape_misc: bool,
pub escape_ascii: bool,
pub code_language: String,
pub autolinks: bool,
pub default_title: bool,
pub br_in_tables: bool,
pub compact_tables: bool,
pub highlight_style: HighlightStyle,
pub extract_metadata: bool,
pub whitespace_mode: WhitespaceMode,
pub strip_newlines: bool,
pub wrap: bool,
pub wrap_width: usize,
pub convert_as_inline: bool,
pub sub_symbol: String,
pub sup_symbol: String,
pub newline_style: NewlineStyle,
pub code_block_style: CodeBlockStyle,
pub keep_inline_images_in: Vec<String>,
pub preprocessing: PreprocessingOptions,
pub encoding: String,
pub debug: bool,
pub strip_tags: Vec<String>,
pub preserve_tags: Vec<String>,
pub skip_images: bool,
pub url_escape_style: UrlEscapeStyle,
pub link_style: LinkStyle,
pub output_format: OutputFormat,
pub include_document_structure: bool,
pub extract_images: bool,
pub max_image_size: u64,
pub capture_svg: bool,
pub infer_dimensions: bool,
pub max_depth: Option<usize>,
pub exclude_selectors: Vec<String>,
pub tier_strategy: TierStrategy,
}Expand description
Main conversion options for HTML to Markdown conversion.
Use ConversionOptions::builder() to construct, or Default::default() for defaults.
§Example
use html_to_markdown_rs::{ConversionOptions, HeadingStyle};
let options = ConversionOptions::builder()
.heading_style(HeadingStyle::Atx)
.wrap(true)
.wrap_width(100)
.build();Fields§
§heading_style: HeadingStyleHeading style to use in Markdown output (ATX # or Setext underline).
list_indent_type: ListIndentTypeHow to indent nested list items (spaces or tab).
list_indent_width: usizeNumber of spaces (or tabs) to use for each level of list indentation.
bullets: StringBullet character(s) to use for unordered list items (e.g. "-", "*").
strong_em_symbol: charCharacter used for bold/italic emphasis markers (* or _).
escape_asterisks: boolEscape * characters in plain text to avoid unintended bold/italic.
escape_underscores: boolEscape _ characters in plain text to avoid unintended bold/italic.
escape_misc: boolEscape miscellaneous Markdown metacharacters ([]()# etc.) in plain text.
escape_ascii: boolEscape ASCII characters that have special meaning in certain Markdown dialects.
code_language: StringDefault language annotation for fenced code blocks that have no language hint.
autolinks: boolAutomatically convert bare URLs into Markdown autolinks.
default_title: boolEmit a default title when no <title> tag is present.
br_in_tables: boolRender <br> elements inside table cells as literal line breaks.
compact_tables: boolEmit tables without column padding (compact GFM format).
When true, column widths are not computed and cells are emitted with
no trailing spaces. Separator rows use exactly --- per column.
Produces token-efficient output suitable for RAG / LLM contexts.
Default false (aligned padding preserved).
highlight_style: HighlightStyleStyle used for <mark> / highlighted text (e.g. ==text==).
extract_metadata: boolPopulate result.metadata with <head> / <meta> extraction
(title, description, Open Graph, Twitter Card, JSON-LD, …).
Default true. Disabling skips the metadata pass only — table
extraction into result.tables runs unconditionally.
whitespace_mode: WhitespaceModeControls how whitespace sequences are normalised in the converted output.
WhitespaceMode::Normalized(default) — collapses consecutive whitespace characters (spaces, tabs, newlines) to a single space, matching browser rendering behaviour.WhitespaceMode::Strict— preserves all whitespace exactly as it appears in the source HTML, including runs of spaces and embedded newlines.
Choose Strict only when the source HTML uses deliberate whitespace (e.g. pre-formatted
content outside <pre> tags). For most documents Normalized produces cleaner output.
strip_newlines: boolStrip all newlines from the output, producing a single-line result.
wrap: boolWrap long lines at wrap_width characters.
wrap_width: usizeMaximum output line width in characters when wrap is true (default 80).
Lines are broken at word boundaries so that no line exceeds this length. A value of 0
is treated as “no limit” — equivalent to leaving wrap disabled. Has no
effect when wrap is false.
convert_as_inline: boolTreat the entire document as inline content (no block-level wrappers).
sub_symbol: StringMarkdown notation for subscript text (e.g. "~").
sup_symbol: StringMarkdown notation for superscript text (e.g. "^").
newline_style: NewlineStyleHow to encode hard line breaks (<br>) in Markdown.
code_block_style: CodeBlockStyleStyle used for fenced code blocks (backticks or tilde).
keep_inline_images_in: Vec<String>HTML tag names whose <img> children are kept inline instead of block.
preprocessing: PreprocessingOptionsOptions for the HTML pre-processing pass applied before conversion begins.
Pre-processing runs before the HTML is handed to the converter and can perform operations
such as unwrapping redundant wrapper elements, removing tracking pixels, and normalising
vendor-specific markup. See PreprocessingOptions for the full set of knobs.
Defaults to PreprocessingOptions::default(), which enables the standard cleaning
passes. Set individual fields on PreprocessingOptions (or construct via
ConversionOptions::builder) to opt in or out of specific passes.
encoding: StringExpected character encoding of the input HTML (default "utf-8").
debug: boolEmit debug information during conversion.
HTML tag names whose content is stripped from the output entirely.
HTML tag names that are preserved verbatim in the output.
skip_images: boolSkip conversion of <img> elements (omit images from output).
url_escape_style: UrlEscapeStyleURL encoding strategy for link and image destinations.
Controls how special characters in URL destinations are escaped:
UrlEscapeStyle::Angle(default) — wraps the destination in angle brackets when it contains spaces or newlines. Some parsers misinterpret>inside such a destination.UrlEscapeStyle::Percent— percent-encodes every character that is not an RFC 3986 unreserved character or/, producing a destination that all Markdown parsers handle correctly even when the URL contains<,>, spaces, or parentheses.
link_style: LinkStyleLink rendering style (inline or reference).
output_format: OutputFormatTarget output format (Markdown, plain text, etc.).
include_document_structure: boolInclude structured document tree in result.
extract_images: boolExtract inline images from data URIs and SVGs.
max_image_size: u64Maximum decoded image size in bytes (default 5MB).
capture_svg: boolCapture SVG elements as images.
infer_dimensions: boolInfer image dimensions from data.
max_depth: Option<usize>Maximum DOM traversal depth. None means unlimited.
When set, subtrees beyond this depth are silently truncated.
exclude_selectors: Vec<String>CSS selectors for elements to exclude entirely (element + all content).
Unlike strip_tags (which removes the tag wrapper but keeps children),
excluded elements and all their descendants are dropped from the output.
Supports any CSS selector that tl supports: tag names, .class,
#id, [attribute], etc.
Invalid selectors are silently skipped at conversion time.
Example: vec![".cookie-banner".into(), "#ad-container".into(), "[role='complementary']".into()]
tier_strategy: TierStrategyWhich conversion tier to use.
TierStrategy::Auto(default) — automatically choose the best path.TierStrategy::Tier2— always use the Tier-2 DOM-walk path.TierStrategy::Tier1— always attempt Tier-1 (testkit only).
Implementations§
Source§impl ConversionOptions
impl ConversionOptions
Sourcepub fn builder() -> ConversionOptionsBuilder
pub fn builder() -> ConversionOptionsBuilder
Create a ConversionOptionsBuilder pre-populated with default values.
All fields start at their documented defaults. Use the setter methods on the returned
builder to override individual fields, then call ConversionOptionsBuilder::build to
produce the final ConversionOptions.
No fields are required — calling .build() immediately yields a valid options struct
identical to ConversionOptions::default().
§Examples
use html_to_markdown_rs::{ConversionOptions, options::validation::{HeadingStyle, WhitespaceMode}};
let options = ConversionOptions::builder()
.heading_style(HeadingStyle::AtxClosed)
.wrap(true)
.wrap_width(100)
.whitespace_mode(WhitespaceMode::Normalized)
.build();
assert_eq!(options.wrap_width, 100);Source§impl ConversionOptions
impl ConversionOptions
Sourcepub fn apply_update(&mut self, update: ConversionOptionsUpdate)
pub fn apply_update(&mut self, update: ConversionOptionsUpdate)
Apply a partial update to these conversion options.
Sourcepub fn from_update(update: ConversionOptionsUpdate) -> Self
pub fn from_update(update: ConversionOptionsUpdate) -> Self
Create from a partial update, applying to defaults.
Trait Implementations§
Source§impl Clone for ConversionOptions
impl Clone for ConversionOptions
Source§fn clone(&self) -> ConversionOptions
fn clone(&self) -> ConversionOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more