Skip to content

Commit

Permalink
馃悰 FIX: Front matter -> sphinx metadata regression (#480)
Browse files Browse the repository at this point in the history
After PR #477, I noted that the `SmartQuote` transform was being applied to  the front-matter values,
before they were extracted to the document metadata (see also issue #479).
Therefore, we now add them as a `literal` to stop this happening.
  • Loading branch information
chrisjsewell committed Dec 29, 2021
1 parent 2b3a931 commit 58f0540
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion myst_parser/docutils_renderer.py
Expand Up @@ -818,7 +818,7 @@ def dict_to_fm_field_list(
if key in bibliofields:
para_nodes, _ = state.inline_text(value, line)
else:
para_nodes = [nodes.Text(value, value)]
para_nodes = [nodes.literal(value, value)]

body_children = [nodes.paragraph("", "", *para_nodes)]
body_children[0].source = self.document["source"]
Expand Down
15 changes: 10 additions & 5 deletions tests/test_renderers/fixtures/docutil_syntax_elements.md
Expand Up @@ -595,19 +595,22 @@ c:
a
<field_body>
<paragraph>
1
<literal>
1
<field>
<field_name>
b
<field_body>
<paragraph>
foo
<literal>
foo
<field>
<field_name>
c
<field_body>
<paragraph>
{"d": 2}
<literal>
{"d": 2}
.

--------------------------
Expand Down Expand Up @@ -725,7 +728,8 @@ other: Something else
other
<field_body>
<paragraph>
Something else
<literal>
Something else
.

--------------------------
Expand Down Expand Up @@ -827,7 +831,8 @@ a = 1
a
<field_body>
<paragraph>
1
<literal>
1
<target ids="target" names="target">
<section ids="header-1" names="header\ 1">
<title>
Expand Down
15 changes: 10 additions & 5 deletions tests/test_renderers/fixtures/sphinx_syntax_elements.md
Expand Up @@ -632,19 +632,22 @@ c:
a
<field_body>
<paragraph>
1
<literal>
1
<field>
<field_name>
b
<field_body>
<paragraph>
foo
<literal>
foo
<field>
<field_name>
c
<field_body>
<paragraph>
{"d": 2}
<literal>
{"d": 2}
.
--------------------------
Expand Down Expand Up @@ -762,7 +765,8 @@ other: Something else
other
<field_body>
<paragraph>
Something else
<literal>
Something else
.
--------------------------
Expand Down Expand Up @@ -864,7 +868,8 @@ a = 1
a
<field_body>
<paragraph>
1
<literal>
1
<target ids="target" names="target">
<section ids="header-1" names="header\ 1">
<title>
Expand Down
2 changes: 2 additions & 0 deletions tests/test_sphinx/sourcedirs/basic/content.md
Expand Up @@ -17,6 +17,8 @@ dedication: |
abstract:
Something something **dark** side
other: Something else
other_dict:
key: value
---

(target)=
Expand Down
1 change: 1 addition & 0 deletions tests/test_sphinx/test_sphinx_builds.py
Expand Up @@ -66,6 +66,7 @@ def test_basic(
"date": "2/12/1985",
"copyright": "MIT",
"other": "Something else",
"other_dict": '{"key": "value"}',
"wordcount": {"minutes": 0, "words": 57},
}

Expand Down

0 comments on commit 58f0540

Please sign in to comment.