Skip to content

Commit 43d5c66

Browse files
authored
1 parent a28e9b7 commit 43d5c66

10 files changed

Lines changed: 39 additions & 17 deletions

File tree

docs/api/parsers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pprint(parser.get_active_rules())
112112
{'block': ['front_matter',
113113
'table',
114114
'code',
115-
'math_block_eqno',
115+
'math_block_label',
116116
'math_block',
117117
'fence',
118118
'myst_line_comment',

docs/api/reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Sphinx
3636

3737
.. autoclass:: myst_parser.sphinx_renderer.SphinxRenderer
3838
:special-members: __output__
39-
:members: handle_cross_reference, render_math_block_eqno
39+
:members: handle_cross_reference, render_math_block_label
4040
:undoc-members:
4141
:member-order: alphabetical
4242
:show-inheritance:

myst_parser/docutils_.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from docutils import nodes
99
from docutils.parsers.rst import Parser as RstParser
1010
from markdown_it.token import Token
11-
from markdown_it.utils import AttrDict
1211

1312
from myst_parser.main import MdParserConfig, default_parser
1413

@@ -47,7 +46,7 @@ def parse(self, inputstring: str, document: nodes.document) -> None:
4746
config = MdParserConfig(renderer="docutils")
4847
parser = default_parser(config)
4948
parser.options["document"] = document
50-
env = AttrDict()
49+
env: dict = {}
5150
tokens = parser.parse(inputstring, env)
5251
if not tokens or tokens[0].type != "front_matter":
5352
# we always add front matter, so that we can merge it with global keys,

myst_parser/docutils_renderer.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -784,11 +784,13 @@ def render_table_row(self, token: SyntaxTreeNode) -> None:
784784

785785
def render_math_inline(self, token: SyntaxTreeNode) -> None:
786786
content = token.content
787-
if token.markup == "$$":
788-
# available when dmath_double_inline is True
789-
node = nodes.math_block(content, content, nowrap=False, number=None)
790-
else:
791-
node = nodes.math(content, content)
787+
node = nodes.math(content, content)
788+
self.add_line_and_source_path(node, token)
789+
self.current_node.append(node)
790+
791+
def render_math_inline_double(self, token: SyntaxTreeNode) -> None:
792+
content = token.content
793+
node = nodes.math_block(content, content, nowrap=False, number=None)
792794
self.add_line_and_source_path(node, token)
793795
self.current_node.append(node)
794796

myst_parser/sphinx_parser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from docutils.core import publish_doctree
77
from docutils.parsers.rst import Parser as RstParser
88
from markdown_it.token import Token
9-
from markdown_it.utils import AttrDict
109
from sphinx.application import Sphinx
1110
from sphinx.io import SphinxStandaloneReader
1211
from sphinx.parsers import Parser as SphinxParser
@@ -52,7 +51,7 @@ def parse(self, inputstring: str, document: nodes.document) -> None:
5251
config = document.settings.env.myst_config
5352
parser = default_parser(config)
5453
parser.options["document"] = document
55-
env = AttrDict()
54+
env: dict = {}
5655
tokens = parser.parse(inputstring, env)
5756
if not tokens or tokens[0].type != "front_matter":
5857
# we always add front matter, so that we can merge it with global keys,

myst_parser/sphinx_renderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def render_heading(self, token: SyntaxTreeNode) -> None:
122122
self.doc_env.myst_anchors = True # type: ignore[attr-defined]
123123
section["myst-anchor"] = doc_slug
124124

125-
def render_math_block_eqno(self, token: SyntaxTreeNode) -> None:
125+
def render_math_block_label(self, token: SyntaxTreeNode) -> None:
126126
"""Render math with referencable labels, e.g. ``$a=1$ (label)``."""
127127
label = token.info
128128
content = token.content

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ packages = find:
3939
install_requires =
4040
docutils>=0.15,<0.18
4141
jinja2 # required for substitutions, but let sphinx choose version
42-
markdown-it-py>=1.0.0,<2.0.0
43-
mdit-py-plugins~=0.2.8
42+
markdown-it-py>=1.0.0,<3.0.0
43+
mdit-py-plugins~=0.3.0
4444
pyyaml
4545
sphinx>=3.1,<5
4646
python_requires = >=3.6

tests/test_commonmark/test_commonmark.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ def test_commonmark(entry):
2626
pytest.skip(
2727
"Thematic breaks on the first line conflict with front matter syntax"
2828
)
29-
if entry["example"] == 599: # <http://example.com/\\[\\>\n
30-
# TODO awaiting upstream fix
31-
pytest.skip("url backslash escaping")
3229
test_case = entry["markdown"]
3330
output = to_html(test_case)
3431

tests/test_renderers/fixtures/sphinx_roles.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,22 @@ ref (`sphinx.roles.XRefRole`):
637637
a
638638
.
639639

640+
--------------------------------
641+
ref with line breaks (`sphinx.roles.XRefRole`):
642+
.
643+
{ref}`some
644+
text
645+
<and
646+
a
647+
custom reference>`
648+
.
649+
<document source="notset">
650+
<paragraph>
651+
<pending_xref refdoc="mock_docname" refdomain="std" refexplicit="True" reftarget="and a custom reference" reftype="ref" refwarn="True">
652+
<inline classes="xref std std-ref">
653+
some text
654+
.
655+
640656
--------------------------------
641657
numref (`sphinx.roles.XRefRole`):
642658
.

tests/test_renderers/fixtures/syntax_elements.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,15 @@ Target:
368368
<target ids="target" names="target">
369369
.
370370
371+
--------------------------
372+
Target with whitespace:
373+
.
374+
(target with space)=
375+
.
376+
<document source="notset">
377+
<target ids="target-with-space" names="target\ with\ space">
378+
.
379+
371380
--------------------------
372381
Referencing:
373382
.

0 commit comments

Comments
 (0)