Skip to content

Commit

Permalink
Merge branch 'master' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored Apr 23, 2024
2 parents 81b2961 + 167c902 commit e1a3fb1
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ jobs:
strategy:
fail-fast: false
matrix:
docutils-version: ["0.17", "0.18", "0.19", "0.20"]
docutils-version: ["0.18", "0.19", "0.20", "0.21"]

steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.9"
- name: Install setup
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ of the project.

## A Renderer for markdown-it tokens

At a high level, the MyST parser is an extension of th project. Markdown-It-Py
At a high level, the MyST parser is an extension of the Markdown-It-Py project. Markdown-It-Py
is a well-structured Python parser for CommonMark text. It also defines an extension
point to include more syntax in parsed files. The MyST parser uses this extension
point to define its own syntax options (e.g., for Sphinx roles and directives).
Expand Down
2 changes: 1 addition & 1 deletion docs/syntax/optional.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ MathJax version 3 (see [the document options](https://docs.mathjax.org/en/latest
window.MathJax = {"options": {"processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}
```

This ensurea that MathJax processes only math, identified by the `dollarmath` and `amsmath` extensions, or specified in `math` directives.
This ensures that MathJax processes only math, identified by the `dollarmath` and `amsmath` extensions, or specified in `math` directives.

To change this behaviour, set a custom regex, for identifying HTML classes to process, like `myst_mathjax_classes="math|myclass"`, or set `myst_update_mathjax=False` to inhibit this override and process all HTML elements.

Expand Down
10 changes: 1 addition & 9 deletions myst_parser/mdit_to_docutils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1918,19 +1918,11 @@ def html_meta_to_nodes(
if not data:
return []

try:
meta_cls = nodes.meta
except AttributeError:
# docutils-0.17 or older
from docutils.parsers.rst.directives.html import MetaBody

meta_cls = MetaBody.meta

output = []

for key, value in data.items():
content = str(value or "")
meta_node = meta_cls(content)
meta_node = nodes.meta(content)
meta_node.source = document["source"]
meta_node.line = line
meta_node["content"] = content
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ keywords = [
]
requires-python = ">=3.8"
dependencies = [
"docutils>=0.16,<0.21",
"docutils>=0.18,<0.22",
"jinja2", # required for substitutions, but let sphinx choose version
"markdown-it-py~=3.0",
"mdit-py-plugins~=0.4",
Expand Down Expand Up @@ -70,6 +70,7 @@ rtd = [
testing = [
"beautifulsoup4",
"coverage[toml]",
"defusedxml", # required by sphinx 7.3 testing utils
"pytest>=8,<9",
"pytest-cov",
"pytest-regressions",
Expand Down
9 changes: 8 additions & 1 deletion tests/test_renderers/test_fixtures_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
def test_syntax_elements(file_params, sphinx_doctree_no_tr: CreateDoctree):
sphinx_doctree_no_tr.set_conf({"extensions": ["myst_parser"]})
result = sphinx_doctree_no_tr(file_params.content, "index.md")
file_params.assert_expected(result.pformat("index"), rstrip_lines=True)
pformat = result.pformat("index")
# changed in docutils 0.20.1
pformat = pformat.replace(
'<literal classes="code" language="">', '<literal classes="code">'
)
file_params.assert_expected(pformat, rstrip_lines=True)


@pytest.mark.param_file(FIXTURE_PATH / "sphinx_link_resolution.md")
Expand Down Expand Up @@ -100,6 +105,8 @@ def test_sphinx_directives(file_params, sphinx_doctree_no_tr: CreateDoctree):
),
"",
)
# changed in sphinx 7.3
pformat = pformat.replace("Added in version 0.2", "New in version 0.2")

file_params.assert_expected(pformat, rstrip_lines=True)

Expand Down
1 change: 1 addition & 0 deletions tests/test_sphinx/sourcedirs/heading_slug_func/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

extensions = ["myst_parser"]
exclude_patterns = ["_build"]
suppress_warnings = ["config.cache"]
myst_heading_anchors = 2
myst_heading_slug_func = make_id
23 changes: 15 additions & 8 deletions tests/test_sphinx/test_sphinx_builds.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
"""Uses sphinx's pytest fixture to run builds.
see conftest.py for fixture usage
NOTE: sphinx 3 & 4 regress against different output files,
the major difference being sphinx 4 uses docutils 0.17,
which uses semantic HTML tags
(e.g. converting `<div class="section">` to `<section>`)
"""

from __future__ import annotations
Expand Down Expand Up @@ -162,15 +157,25 @@ def test_references_singlehtml(
docname="other/other",
resolve=True,
regress=True,
replace={"other\\other.md": "other/other.md"},
replace={
"other\\other.md": "other/other.md",
# changed in sphinx 7.3
'="#document-index': '="index.html#document-index',
'="#document-other': '="index.html#document-other',
},
)

get_sphinx_app_output(
app,
filename="index.html",
buildername="singlehtml",
regress_html=True,
replace={"Permalink to this headline": "Permalink to this heading"},
replace={
"Permalink to this headline": "Permalink to this heading",
# changed in sphinx 7.3
'="#document-index': '="index.html#document-index',
'="#document-other': '="index.html#document-other',
},
)


Expand Down Expand Up @@ -469,7 +474,9 @@ def test_gettext_html(
regress_ext=".html",
replace={
# upstream bug https://github.com/sphinx-doc/sphinx/issues/11689
'"Permalink to this heading"': '"Lien permanent vers cette rubrique"'
'"Permalink to this heading"': '"Lien permanent vers cette rubrique"',
# which was fixed to a different translation in sphinx 7.3
'"Lien vers cette rubrique"': '"Lien permanent vers cette rubrique"',
},
)

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# then then deleting compiled files has been found to fix it: `find . -name \*.pyc -delete`

[tox]
envlist = py38-sphinx7
envlist = py39-sphinx7

[testenv]
usedevelop = true
Expand Down

0 comments on commit e1a3fb1

Please sign in to comment.