Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion yardang/conf.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ def run_convert_github_admonitions_to_rst(app, filename, lines):
break
else:
# replace indent to match directive
if replacing and "> " in line:
if replacing and line == ">":
line = ""
elif replacing and "> " in line:
line = line.replace("> ", " ")
elif replacing:
# missing "> ", so stop replacing and terminate directive
Expand Down
17 changes: 17 additions & 0 deletions yardang/tests/test_sphinx.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib.util
from pathlib import Path

from yardang import __version__
Expand All @@ -22,3 +23,19 @@ def test_generated_configuration_enables_extension(tmp_path, monkeypatch):
conf_content = (Path(conf_dir) / "conf.py").read_text()

assert '"yardang.sphinx"' in conf_content


def test_github_admonition_preserves_quoted_blank_lines(tmp_path, monkeypatch):
(tmp_path / "pyproject.toml").write_text('[project]\nname = "test-project"\nversion = "1.0.0"\n')
(tmp_path / "README.md").write_text("# Test Project\n")
monkeypatch.chdir(tmp_path)

with generate_docs_configuration() as conf_dir:
spec = importlib.util.spec_from_file_location("yardang_test_conf", Path(conf_dir) / "conf.py")
conf = importlib.util.module_from_spec(spec)
spec.loader.exec_module(conf)

lines = ["> [!NOTE]\n> First paragraph.\n>\n> Second paragraph."]
conf.run_convert_github_admonitions_to_rst(None, "index.md", lines)

assert lines == [":::{note}\n\n First paragraph.\n\n Second paragraph."]