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
1 change: 0 additions & 1 deletion core/arxiv/submission/domain/event/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ def _acceptable_length(self, submission: Submission) -> None:
@staticmethod
def cleanup(value: str) -> str:
"""Perform some light tidying on the abstract."""
value = re.sub(r"\s+", " ", value) # Single spaces only.
value = value.strip() # Remove leading or trailing spaces
# Tidy paragraphs which should be indicated with "\n ".
value = re.sub(r"[ ]+\n", "\n", value)
Expand Down
52 changes: 52 additions & 0 deletions core/arxiv/submission/domain/event/tests/test_abstract_cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Test abstract cleanup"""

from unittest import TestCase
from .. import SetAbstract
from arxiv.base.filters import abstract_lf_to_br

class TestSetAbstractCleanup(TestCase):
"""Test abstract cleanup"""

def test_paragraph_cleanup(self):
awlb = "Paragraph 1.\n \nThis should be paragraph 2"
self.assertIn('<br', abstract_lf_to_br(awlb),
'sanity check: abstract filter does put <br> in')

e = SetAbstract(creator='xyz', abstract=awlb)
self.assertIn('<br', abstract_lf_to_br(e.abstract),
'.cleanup must preserve <br> creating whitespace')

awlb = "Paragraph 1.\n\t\nThis should be p 2."
e = SetAbstract(creator='xyz', abstract=awlb)
self.assertIn('<br', abstract_lf_to_br(e.abstract),
'.cleanup must preserve <br> creating whitespace (tab)')

awlb = "Paragraph 1.\n \nThis should be p 2."
e = SetAbstract(creator='xyz', abstract=awlb)
self.assertIn('<br', abstract_lf_to_br(e.abstract),
'.cleanup must preserve <br> creating whitespace')

awlb = "Paragraph 1.\n \t \nThis should be p 2."
e = SetAbstract(creator='xyz', abstract=awlb)
self.assertIn('<br', abstract_lf_to_br(e.abstract),
'.cleanup must preserve <br> creating whitespace')

awlb = "Paragraph 1.\n \nThis should be p 2."
e = SetAbstract(creator='xyz', abstract=awlb)
self.assertIn('<br', abstract_lf_to_br(e.abstract),
'.cleanup must preserve <br> creating whitespace')

awlb = "Paragraph 1.\n This should be p 2."
e = SetAbstract(creator='xyz', abstract=awlb)
self.assertIn('<br', abstract_lf_to_br(e.abstract),
'.cleanup must preserve <br> creating whitespace')

awlb = "Paragraph 1.\n\tThis should be p 2."
e = SetAbstract(creator='xyz', abstract=awlb)
self.assertIn('<br', abstract_lf_to_br(e.abstract),
'.cleanup must preserve <br> creating whitespace')

awlb = "Paragraph 1.\n This should be p 2."
e = SetAbstract(creator='xyz', abstract=awlb)
self.assertIn('<br', abstract_lf_to_br(e.abstract),
'.cleanup must preserve <br> creating whitespace')