Markdownify Integration
pymdtools.markdownify_integration is the thin wrapper around the external
markdownify package. It replaces the old vendored implementation with a
single compatibility point and re-exports the symbols historically used by
pymdtools callers.
Common Usage
Convert HTML to Markdown:
from pymdtools.markdownify_integration import markdownify
markdown = markdownify("<h1>Title</h1>")
Backend helpers expose the active backend name and version for diagnostics.
Public API
Markdownify integration helpers.
This module is the single integration point between pymdtools and the
external markdownify package. It replaces the historical vendored
implementation with a thin compatibility layer over the maintained dependency.
Responsibilities:
fail early when the installed
markdownifypackage misses expected API symbols;re-export the converter class and heading-style constants used by older pymdtools callers;
provide a typed
markdownifyhelper and backend metadata functions.
Typical usage:
>>> markdownify("<h1>Title</h1>").strip()
'Title\n====='
- class pymdtools.markdownify_integration.MarkdownConverter(**options)
Bases:
object- class DefaultOptions
Bases:
object- autolinks = True
- bs4_options = 'html.parser'
- bullets = '*+-'
- code_language = ''
- code_language_callback = None
- convert = None
- default_title = False
- escape_asterisks = True
- escape_misc = False
- escape_underscores = True
- heading_style = 'underlined'
- keep_inline_images_in = []
- newline_style = 'spaces'
- strip = None
- strip_document = 'strip'
- strip_pre = 'strip'
- strong_em_symbol = '*'
- sub_symbol = ''
- sup_symbol = ''
- table_infer_header = False
- wrap = False
- wrap_width = 80
- class Options
Bases:
DefaultOptions
- convert(html)
- convert__document_(el, text, parent_tags)
Final document-level formatting for BeautifulSoup object (node.name == “[document]”)
- convert_a(el, text, parent_tags)
- convert_article(el, text, parent_tags)
- convert_b(el, text, parent_tags)
- convert_blockquote(el, text, parent_tags)
- convert_br(el, text, parent_tags)
- convert_caption(el, text, parent_tags)
- convert_code(el, text, parent_tags)
- convert_dd(el, text, parent_tags)
- convert_del(el, text, parent_tags)
- convert_div(el, text, parent_tags)
- convert_dl(el, text, parent_tags)
- convert_dt(el, text, parent_tags)
- convert_em(el, text, parent_tags)
- convert_figcaption(el, text, parent_tags)
- convert_hN(n, el, text, parent_tags)
- convert_hr(el, text, parent_tags)
- convert_i(el, text, parent_tags)
- convert_img(el, text, parent_tags)
- convert_kbd(el, text, parent_tags)
- convert_li(el, text, parent_tags)
- convert_list(el, text, parent_tags)
- convert_ol(el, text, parent_tags)
- convert_p(el, text, parent_tags)
- convert_pre(el, text, parent_tags)
- convert_q(el, text, parent_tags)
- convert_s(el, text, parent_tags)
- convert_samp(el, text, parent_tags)
- convert_script(el, text, parent_tags)
- convert_section(el, text, parent_tags)
- convert_soup(soup)
- convert_strong(el, text, parent_tags)
- convert_style(el, text, parent_tags)
- convert_sub(el, text, parent_tags)
- convert_sup(el, text, parent_tags)
- convert_table(el, text, parent_tags)
- convert_td(el, text, parent_tags)
- convert_th(el, text, parent_tags)
- convert_tr(el, text, parent_tags)
- convert_ul(el, text, parent_tags)
- convert_video(el, text, parent_tags)
- escape(text, parent_tags)
- get_conv_fn(tag_name)
Given a tag name, find and return the conversion function.
- get_conv_fn_cached(tag_name)
Given a tag name, return the conversion function using the cache.
- process_element(node, parent_tags=None)
- process_tag(node, parent_tags=None)
- process_text(el, parent_tags=None)
- should_convert_tag(tag)
Given a tag name, return whether to convert based on strip/convert options.
- underline(text, pad_char)
- pymdtools.markdownify_integration.get_backend_name() str
Return the active HTML-to-Markdown backend name.
- Returns:
Always
"markdownify".
- pymdtools.markdownify_integration.get_backend_version() str
Return the installed markdownify package version.
- Returns:
Package metadata version when available, otherwise
"unknown".
- pymdtools.markdownify_integration.markdownify(html: str, **options: Any) str
Convert HTML text to Markdown using the external
markdownifypackage.- Parameters:
html – HTML fragment or document to convert.
**options – Options forwarded to
markdownify.markdownify.
- Returns:
Converted Markdown text.