Skip to content

MarkdownParser

Sub classes

Name Children Inherits
CmarkgfmParser
mkconvert.parsers.cmarkgfm
cmarkgfm: bindings to cmark-gfm, the reference GFM implementation.
    ComrakParser
    mkconvert.parsers.comrak
    Comrak: fast, CommonMark / GFM compliant, supports every common option.
      Markdown2Parser
      mkconvert.parsers.markdown2
      markdown2: pure-Python Markdown (not CommonMark compliant), many "extras".
        MarkdownItPyParser
        mkconvert.parsers.markdown_it_py
        markdown-it-py + mdit-py-plugins: pure Python, CommonMark compliant, pluggable.
          MarkdownItPyrsParser
          mkconvert.parsers.markdown_it_pyrs
          markdown-it-pyrs: Rust port of markdown-it. Deprecated, removed in mkconvert 3.0.
            MarkoParser
            mkconvert.parsers.marko
            Marko: pure-Python CommonMark parser, extensible.
              MistuneParser
              mkconvert.parsers.mistune
              Mistune: fast pure-Python parser (not fully CommonMark compliant).
                PyromarkParser
                mkconvert.parsers.pyromark
                Pyromark: bindings to pulldown-cmark, very fast.
                  PythonMarkdownParser
                  mkconvert.parsers.python_markdown
                  Python-Markdown with pymdown-extensions (not CommonMark compliant).

                    Base classes

                    Name Children Inherits
                    Backend
                    mkconvert._core
                    Base class for Markdown parsers and HTML-to-Markdown converters.

                    ⋔ Inheritance diagram

                    graph TD
                      2536207506["base.MarkdownParser"]
                      1836221132["_core.Backend"]
                      925645236["abc.ABC"]
                      2751680898["builtins.object"]
                      3481597255["typing.Generic"]
                      1836221132 --> 2536207506
                      925645236 --> 1836221132
                      2751680898 --> 925645236
                      3481597255 --> 1836221132
                      2751680898 --> 3481597255

                    🛈 DocStrings

                    Bases: Backend[MarkdownOptions]

                    Base class for Markdown -> HTML parsers.

                    Subclasses take MarkdownOptions plus their own keyword-only options, map them onto the wrapped library once in __init__ and implement _render.

                    Source code in src/mkconvert/parsers/base.py
                    class MarkdownParser(Backend[MarkdownOptions]):
                        """Base class for Markdown -> HTML parsers.
                    
                        Subclasses take `MarkdownOptions` plus their own keyword-only options, map them onto
                        the wrapped library once in `__init__` and implement `_render`.
                        """
                    
                        options_class: ClassVar[type[MarkdownOptions]] = MarkdownOptions
                    
                        def convert(self, text: str) -> str:
                            """Convert Markdown `text` to HTML."""
                            if self.options.front_matter:
                                _, text = split_front_matter(text)
                            return self._render(text)
                    
                        @abstractmethod
                        def _render(self, text: str) -> str:
                            """Render Markdown to HTML with the wrapped library."""
                    

                    convert

                    convert(text: str) -> str
                    

                    Convert Markdown text to HTML.

                    Source code in src/mkconvert/parsers/base.py
                    def convert(self, text: str) -> str:
                        """Convert Markdown `text` to HTML."""
                        if self.options.front_matter:
                            _, text = split_front_matter(text)
                        return self._render(text)
                    

                    :fa-brands-github: Show source on GitHub