mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-09 08:51:54 -04:00
nanorst: do not require 2 empty lines at end of string after code block, fixes #9714
This commit is contained in:
parent
043628cdd8
commit
1f00a1f4f3
2 changed files with 12 additions and 0 deletions
|
|
@ -159,6 +159,12 @@ def rst_to_text(text, state_hook=None, references=None):
|
|||
state = "text"
|
||||
out.write(char)
|
||||
|
||||
if state == "code-block":
|
||||
# without this, we would need 2 empty lines after a code block,
|
||||
# even if it is at the end of the string anyway.
|
||||
state_hook(state, "text", out)
|
||||
state = "text"
|
||||
|
||||
assert state == "text", "Invalid final state %r (This usually indicates unmatched */**)" % state
|
||||
return out.getvalue()
|
||||
|
||||
|
|
|
|||
|
|
@ -36,3 +36,9 @@ def test_undefined_ref():
|
|||
with pytest.raises(ValueError) as exc_info:
|
||||
rst_to_text("See :ref:`foo`.")
|
||||
assert "Undefined reference" in str(exc_info.value)
|
||||
|
||||
|
||||
def test_code_block_end_of_string():
|
||||
# check that there is no unexpected exception if a code block
|
||||
# is not followed by blank lines, but the string just ends.
|
||||
assert rst_to_text("This is a code block::\n\n borg --help") == "This is a code block:\n\n borg --help"
|
||||
|
|
|
|||
Loading…
Reference in a new issue