Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix screen linebreaks #737

Merged
merged 27 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
da681cf
First attempt of fixing <screen>s
tomschr Aug 29, 2024
a738a9c
Save as .new
tomschr Aug 29, 2024
689effa
Move to bin, create link
tomschr Aug 29, 2024
c93d417
Fix bug in replace_entities_with_braces, add test
tomschr Aug 29, 2024
89c2e62
Test extract_screen_blocks()
tomschr Aug 29, 2024
188e60f
Introduce xmlparser()
tomschr Aug 29, 2024
de87707
Test is_screen_content_text_only
tomschr Aug 29, 2024
46ecf73
Test and fix modify_screen_with_text_only()
tomschr Aug 29, 2024
c3db63c
Test modify_screen_with_prompt()
tomschr Aug 29, 2024
403c398
Test modify_screen_with_prompt()
tomschr Aug 29, 2024
d36d887
Fix bug in replace_entities_with_braces regex
tomschr Aug 29, 2024
304eda0
Fix test case test_modify_screen_with_prompt_entity
tomschr Aug 29, 2024
a52d083
Fix regex for restore_entities_from_braces
tomschr Aug 29, 2024
8037100
Add --stdout option
tomschr Aug 29, 2024
86f5933
Allow **args for xmlparser()
tomschr Aug 30, 2024
2a1cdc1
Fix modify_screen_with_prompt(screen)
tomschr Aug 30, 2024
e82cb0c
Fix test_modify_screen_with_prompt_entity()
tomschr Aug 30, 2024
1b19ce3
Fix test_replace_screen_blocks()
tomschr Aug 30, 2024
671f12e
Introduce test_replace_screen_blocks_with_prompt_entity
tomschr Aug 30, 2024
20952ad
Check if screen.text is None
tomschr Aug 30, 2024
9241dfb
Add use case prompt + two commands
tomschr Aug 30, 2024
9fd2d8b
Reduce many spaces to one
tomschr Aug 30, 2024
0ad7bde
Fix test_modify_screen_with_text_only
tomschr Aug 30, 2024
1fd6b63
Implement better algorithm for prompts + other inlines
tomschr Aug 30, 2024
384509e
Add setup.py/setup.cfg
tomschr Aug 30, 2024
aaf1ff3
Add tests and .gitignore
tomschr Sep 2, 2024
50b8011
Add README
tomschr Sep 4, 2024
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
Prev Previous commit
Next Next commit
Reduce many spaces to one
  • Loading branch information
tomschr committed Aug 30, 2024
commit 9fd2d8b1de6fec529029b2e35a8b48c83f570549
3 changes: 2 additions & 1 deletion python-scripts/fix-screen/bin/fix-screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
re.escape(START_DELIMITER),
re.escape(END_DELIMITER))
)
SPACES = re.compile(r' +')


def stderr(*args, **kwargs):
Expand Down Expand Up @@ -156,7 +157,7 @@ def modify_screen_with_prompt(screen):
# <command> or <replaceable> element
if screen[1].tail is not None:
# Only strip linebreaks, but not spaces
screen[1].tail = screen[1].tail.strip('\n')
screen[1].tail = SPACES.sub(" ", screen[1].tail).strip('\n')


def modify_screen_content(screen_content: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion python-scripts/fix-screen/tests/test_modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_replace_screen_blocks_with_prompt_and_two_commands():
"<screen>"
"<prompt>&lt;</prompt>"
"<command>sudo</command>"
" <command>ls</command>\n"
" <command>ls</command>\n"
"</screen>\n"
"<para>Other text</para>"
)
Loading