Skip to content

Commit

Permalink
Merge pull request #521 from asimon-1/reorder-backslashes
Browse files Browse the repository at this point in the history
Handle backslashes in Reorder operations
  • Loading branch information
jacebrowning committed Sep 2, 2021
2 parents f560e9c + 5a772c0 commit 902f501
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions doorstop/cli/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,20 @@ def test_reorder_document_unknown(self):
"""Verify 'doorstop reorder' returns an error on an unknown prefix."""
self.assertRaises(SystemExit, main, ['reorder', 'FAKE'])

def test_reorder_with_backslashes_in_text(self):
"""Verify 'doorstop reorder' can handle text with backslashes."""
number = get_next_number()
filename = "TUT{}.yml".format(str(number).zfill(3))
path = os.path.join(TUTORIAL, filename)
with open(path, "w") as f:
f.write(
"""active: true\nderived: false\nheader: ''\nlevel: 2.4\nlinks: []\n"""
"""normative: true\nref: ''\nreviewed: null\ntext: |\n Equation """
"""$Eqn = \\frac{a}{b} * \\sigma$"""
)
self.addCleanup(os.remove, path)
self.assertIs(None, main(['reorder', self.prefix, "--auto"]))


@unittest.skipUnless(os.getenv(ENV), REASON)
@patch('doorstop.settings.SERVER_HOST', None)
Expand Down
2 changes: 1 addition & 1 deletion doorstop/core/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def _lines_index(items):
for item in items:
space = " " * item.depth
lines = item.text.strip().splitlines()
comment = lines[0] if lines else ""
comment = lines[0].replace("\\", "\\\\") if lines else ""
line = space + "- {u}: # {c}".format(u=item.uid, c=comment)
if len(line) > settings.MAX_LINE_LENGTH:
line = line[: settings.MAX_LINE_LENGTH - 3] + '...'
Expand Down

0 comments on commit 902f501

Please sign in to comment.