MyST-Parser icon indicating copy to clipboard operation
MyST-Parser copied to clipboard

Unable to modify Sphinx configuration for main.to_docutils function

Open ashwinvis opened this issue 3 years ago • 1 comments

Describe the bug

I am trying to use MyST-parser as a reader for Pelican static site generator. I would like to use citation and bibliography rendering capabilities. If I understood correctly, the myst_parser.main.to_docutils function would process it via a Sphinx application. Initially I tried something like

    def _run_myst_to_html(self, content):
        """Execute the MyST parser and return output."""
        sphinx_conf = dict(
            extensions=["myst_parser", "sphinxcontrib.bibtex"],
        )
        return main.to_docutils(
            content,
            parser_config=self.parser_config,
            conf=sphinx_conf,
            in_sphinx_env=True
        )

However I the configuration did not seem to work. I managed to track it down to the mock_sphinx_env function.

To Reproduce

Steps to reproduce the behavior:

  1. Execute this test using pytest
from myst_parser.sphinx_renderer import (
    mock_sphinx_env,
    minimal_sphinx_app,
)
from myst_parser.docutils_renderer import make_document


def test_myst_mock_sphinx_env():
    conf = {"extensions": ["sphinxcontrib.bibtex"]}
    requested_extensions = set(conf.get("extensions"))
    with mock_sphinx_env(conf=conf, srcdir=".", document=make_document()) as app:
        app_exts = sorted(app.extensions)
        assert (
            requested_extensions.intersection(app_exts) == requested_extensions
        ), f"requested {requested_extensions}, got {app_exts}"

Expected behavior

It should be possible to pass on additional Sphinx configuration using the API.

A link to your repository.

https://github.com/ashwinvis/myst-reader/pull/1

Environment

  • Python Version [e.g. 3.7.1]: 3.8.1
  • Package versions or output of jupyter-book --version: Not using jupyter-book, but myst-parser 0.13.5
  • Operating System: Linux

ashwinvis avatar Mar 14 '21 16:03 ashwinvis

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Mar 14 '21 16:03 welcome[bot]

Closing because the functions have been removed in 0.18.0

ashwinvis avatar Sep 25 '22 19:09 ashwinvis