Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ NEW: Add
myst_title_to_header
configuration (#492)
Setting `myst_title_to_header = True` allows for the value of a `title` key, in the Markdown front-matter, to be treated as the initial H1 header (the value will be parsed as Markdown).
- Loading branch information
1 parent
74e91e6
commit 574b525
Showing
7 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[title-to-header] --myst-title-to-header="yes" | ||
. | ||
--- | ||
title: "The title *nested syntax*" | ||
--- | ||
|
||
# Other header | ||
. | ||
<document source="<string>"> | ||
<docinfo> | ||
<field classes="title"> | ||
<field_name> | ||
title | ||
<field_body> | ||
<paragraph> | ||
<literal> | ||
The title *nested syntax* | ||
<section ids="the-title-nested-syntax" names="the\ title\ nested\ syntax"> | ||
<title> | ||
The title | ||
<emphasis> | ||
nested syntax | ||
<section ids="other-header" names="other\ header"> | ||
<title> | ||
Other header | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Test (docutils) parsing with different ``MdParserConfig`` options set.""" | ||
import shlex | ||
from io import StringIO | ||
from pathlib import Path | ||
|
||
from docutils.core import Publisher, publish_doctree | ||
from pytest_param_files import with_parameters | ||
|
||
from myst_parser.docutils_ import Parser | ||
|
||
FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures") | ||
|
||
|
||
@with_parameters(FIXTURE_PATH / "myst-config.txt") | ||
def test_cmdline(file_params): | ||
"""The description is parsed as a docutils commandline""" | ||
pub = Publisher(parser=Parser()) | ||
option_parser = pub.setup_option_parser() | ||
try: | ||
settings = option_parser.parse_args( | ||
shlex.split(file_params.description) | ||
).__dict__ | ||
except Exception as err: | ||
raise AssertionError( | ||
f"Failed to parse commandline: {file_params.description}\n{err}" | ||
) | ||
report_stream = StringIO() | ||
settings["warning_stream"] = report_stream | ||
doctree = publish_doctree( | ||
file_params.content, | ||
parser=Parser(), | ||
settings_overrides=settings, | ||
) | ||
file_params.assert_expected(doctree.pformat(), rstrip_lines=True) |