Skip to content

Commit

Permalink
Merge pull request #579 from Fortran-FOSS-Programmers/fix-adminition-…
Browse files Browse the repository at this point in the history
…no-new-line

Fix admonitions without a trailing newline
  • Loading branch information
ZedThree authored Oct 26, 2023
2 parents 32d6044 + 2910c7d commit 3012896
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ford/md_admonition.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ def _process_admonitions(
admonition.end_idx += 1

# Indent any intermediate lines
for idx in range(admonition.start_idx + 1, admonition.end_idx + 1):
end_line = min(len(lines), admonition.end_idx + 1)
for idx in range(admonition.start_idx + 1, end_line):
if lines[idx] != "":
lines[idx] = self.INDENT + lines[idx]

Expand Down
18 changes: 18 additions & 0 deletions test/test_md_admonition.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@ def test_explicit_end():
assert soup.div.text.strip() == "Note\nnote text\nsome blank lines\nbefore the end"


def test_explicit_end_no_newline():
converted = convert(
"""
@note note text
some blank lines
before the end
@endnote"""
)

soup = BeautifulSoup(converted, features="html.parser")
assert len(soup) == 1
assert sorted(soup.div["class"]) == ["alert", "alert-info"]
assert soup.find(class_="h4").text == "Note"
assert soup.div.text.strip() == "Note\nnote text\nsome blank lines\nbefore the end"


def test_warning():
converted = convert(
"""
Expand Down

0 comments on commit 3012896

Please sign in to comment.