Skip to content

KeyError: 'writer' with myST-Parser since PR #13676 #13713

@jfbu

Description

@jfbu

Describe the bug

make html fails with error KeyError: 'writer' in presence of myST-Parser and meta data at start of index.md.

How to Reproduce

Use this file index.md:

---
myst:
  html_meta:
    keywords: Bug
---

# FOO documentation

and make sure conf.py contains:

extensions = [
    'myst_parser',
]
source_suffix = {
    '.rst': 'restructuredtext',
    '.md': 'markdown',
}

Environment Information

$ make clean html
Removing everything under '_build'...
Running Sphinx v8.3.0+/114093cff
Sphinx version: 8.3.0+/114093cff
Python version: 3.13.3 (CPython)
Docutils version: 0.21.2 
Pygments version: 2.19.1
Jinja2 version: 3.1.6

loading translations [en]... done
making output directory... done
myst v4.0.1: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=set(), disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_sort=True, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
building [mo]: targets for 0 po files that are out of date
writing output... 
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index

Versions
========

* Platform:         darwin; macOS 15.5 arm64
* Python version:   3.13.3 (CPython)
* Sphinx version:   8.3.0+/114093cff
* Docutils version: 0.21.2
* Jinja2 version:   3.1.6
* Pygments version: 2.19.1

Last Messages
=============

    writing output...

    building [html]: targets for 1 source files that are out of date
    updating environment:
    [new config]
    1 added, 0 changed, 0 removed

    reading sources... [100%]
    index

Loaded Extensions
=================

* sphinx.ext.mathjax (8.3.0+/114093cff)
* alabaster (1.0.0)
* sphinxcontrib.applehelp (2.0.0)
* sphinxcontrib.devhelp (2.0.0)
* sphinxcontrib.htmlhelp (2.1.0)
* sphinxcontrib.serializinghtml (2.0.0)
* sphinxcontrib.qthelp (2.0.0)
* myst_parser (4.0.1)

Traceback
=========

      File "/path/to/.venv313/lib/python3.13/site-packages/docutils/transforms/components.py", line 48, in apply
        component = self.document.transformer.components[component_type]
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
    KeyError: 'writer'

Sphinx extensions

``myST-Parser 4.0.1``

Additional context

git bisect blames 114093c (#13676)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions