{"record":{"id":"89488f9cf92c7116","repo":"docling-project/docling","slug":"the-marko-package-is-required-to-process-markdow","errorCode":null,"errorMessage":"The 'marko' package is required to process Markdown files. Install it with `pip install 'docling-slim[format-markdown]'`.","messagePattern":"The 'marko' package is required to process Markdown files\\. Install it with `pip install 'docling-slim\\[format-markdown\\]'`\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"docling/backend/md_backend.py","lineNumber":230,"sourceCode":"        )\n        shortened_text, count = pattern.subn(r\"\\1- \", markdown_text)\n\n        if count > 0:\n            warnings.warn(\"Detected potentially incorrect Markdown, correcting...\")\n\n        return shortened_text\n\n    @override\n    def __init__(\n        self,\n        in_doc: InputDocument,\n        path_or_stream: Union[BytesIO, Path],\n        options: Optional[MarkdownBackendOptions] = None,\n    ):\n        # Raised first so a missing optional dependency gives an actionable\n        # message rather than a NameError when marko is dereferenced below.\n        if not _MARKO_AVAILABLE:\n            raise ImportError(_INSTALL_HINT) from _MARKO_IMPORT_ERROR\n        if options is None:\n            options = MarkdownBackendOptions()\n        super().__init__(in_doc, path_or_stream, options)\n\n        _log.debug(\"Starting MarkdownDocumentBackend...\")\n\n        # Markdown file:\n        self.path_or_stream = path_or_stream\n        self.valid = True\n        self.markdown = \"\"  # To store original Markdown string\n\n        self.in_table = False\n        self.in_pipeless_table = False\n        self.md_table_buffer: list[str] = []\n        self._html_blocks: int = 0\n        self._image_loader: Optional[ImageResourceLoader] = None\n\n        try:","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/backend/md_backend.py#L212-L248","documentation":"MarkdownDocumentBackend.__init__ raises ImportError before super().__init__() when marko is unavailable, chaining the original import error. The check runs first specifically so a missing dependency yields this actionable message instead of a NameError when marko is first dereferenced during parsing.","triggerScenarios":"Converting Markdown files (InputFormat.MARKDOWN) with docling-slim installed but the format-markdown extra (marko) missing.","commonSituations":"Slim installs chosen for image size; enabling Markdown conversion later without updating requirements; CI environments built from stale lockfiles.","solutions":["Install the extra: pip install 'docling-slim[format-markdown]'","Or install the full docling package","Verify the extra is present in Docker/CI dependency specs"],"exampleFix":"# before\npip install docling-slim\n\n# after\npip install 'docling-slim[format-markdown]'","handlingStrategy":"validation","validationCode":"try:\n    import marko  # noqa: F401\nexcept ImportError:\n    raise RuntimeError(\"Install: pip install 'docling-slim[format-markdown]'\")","typeGuard":null,"tryCatchPattern":"try:\n    result = converter.convert(src)\nexcept ImportError as exc:\n    if 'marko' in str(exc):\n        install_or_skip('docling-slim[format-markdown]')\n    raise","preventionTips":["Declare the format-markdown extra in dependency specs","Probe optional imports at startup for all accepted formats"],"tags":["markdown","optional-dependency","installation","importerror"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}