diff --git a/CHANGELOG.md b/CHANGELOG.md index 60011f95b9..b2dfdcdf9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,8 @@ - [Fix][issue3312]: Handle all edge cases breaking `monitor/monitored` `input_funcs` (Griatch) - [Fix][issue3154]: Persistent EvMenu caused multiple cmdsets on reload (Griatch) - [Fix][issue3193]: Formatting of inner nested evtable would break (Griatch) +- [Fix][issue3082]: MXP linking broke EvTable formatting (Griatch) +- [Fix][issue3693]: MXP linking broke EvTable formatting (Griatch) - [Doc][pull3801]: Move Evennia doc build system to latest Sphinx/myST (PowershellNinja, also honorary mention to electroglyph) - [Doc][pull3800]: Describe support for Telnet SSH in HAProxy documentation (holl0wstar) @@ -81,6 +83,8 @@ [issue3312]: https://github.com/evennia/evennia/issues/3312 [issue3154]: https://github.com/evennia/evennia/issues/3154 [issue3193]: https://github.com/evennia/evennia/issues/3193 +[issue3082]: https://github.com/evennia/evennia/issues/3082 +[issue3693]: https://github.com/evennia/evennia/issues/3693 ## Evennia 5.0.1 diff --git a/evennia/utils/evtable.py b/evennia/utils/evtable.py index 181d57e4f8..727fc122da 100644 --- a/evennia/utils/evtable.py +++ b/evennia/utils/evtable.py @@ -119,7 +119,7 @@ from textwrap import TextWrapper from django.conf import settings -from evennia.utils.ansi import ANSIString +from evennia.utils.ansi import ANSIString, strip_mxp from evennia.utils.utils import display_len as d_len from evennia.utils.utils import is_iter, justify @@ -137,7 +137,7 @@ def _to_ansi(obj): if is_iter(obj): return [_to_ansi(o) for o in obj] else: - return ANSIString(obj) + return ANSIString(strip_mxp(str(obj))) _whitespace = "\t\n\x0b\x0c\r " @@ -487,6 +487,7 @@ class EvCell: Returns: split (list): split text. """ + text = text.replace("\r\n", "\n").replace("\r", "\n") return text.split("\n") def _fit_width(self, data): @@ -558,7 +559,9 @@ class EvCell: aligned = [] for line in data: # Preserve manually spaced/pre-formatted lines (like nested tables). - if " " in line or (line and (line[0].isspace() or line[-1].isspace())): + raw_line = line.raw() if hasattr(line, "raw") else str(line) + has_link_markup = strip_mxp(raw_line) != raw_line + if " " in line or has_link_markup: line_width = d_len(line) if line_width >= width: aligned.append(justify(line, width, align="a", fillchar=hfill_char)) diff --git a/evennia/utils/tests/test_evtable.py b/evennia/utils/tests/test_evtable.py index e4a5f41339..cd7de37993 100644 --- a/evennia/utils/tests/test_evtable.py +++ b/evennia/utils/tests/test_evtable.py @@ -3,8 +3,6 @@ Tests for EvTable component. """ -from unittest import skip - from evennia.utils import ansi, evtable from evennia.utils.test_resources import EvenniaTestCase @@ -387,7 +385,6 @@ class TestEvTable(EvenniaTestCase): self.assertIn(ANSI_RED, str(table)) self.assertIn(ANSI_CYAN, str(table)) - @skip("Pending refactor into client-side ansi parsing") def test_mxp_links(self): """ Testing https://github.com/evennia/evennia/issues/3082 @@ -399,31 +396,19 @@ class TestEvTable(EvenniaTestCase): commands1 = [f"|lcsay This is command {inum}|ltcommand {inum}|le" for inum in range(1, 4)] commands2 = [f"command {inum}" for inum in range(1, 4)] # comparison strings, no MXP - # from evennia import set_trace - - # set_trace() - cell1 = ansi.strip_mxp(str(evtable.EvCell(f"|lcsay This is command 1|ltcommand 1|le"))) cell2 = str(evtable.EvCell(f"command 1")) - print(f"cell1:------------\n{cell1}") - print(f"cell2:------------\n{cell2}") - table1a = ansi.strip_mxp(str(evtable.EvTable(*commands1))) table1b = str(evtable.EvTable(*commands2)) table2a = ansi.strip_mxp(str(evtable.EvTable(table=[commands1]))) table2b = str(evtable.EvTable(table=[commands2])) - print(f"1a:---------------\n{table1a}") - print(f"1b:---------------\n{table1b}") - print(f"2a:---------------\n{table2a}") - print(f"2b:---------------\n{table2b}") - + self.assertEqual(cell2, cell1) self.assertEqual(table1b, table1a) self.assertEqual(table2b, table2a) - @skip("Needs to be further invstigated") def test_formatting_with_carriage_return_marker_3693_a(self): """ Testing of issue https://github.com/evennia/evennia/issues/3693 @@ -443,7 +428,6 @@ class TestEvTable(EvenniaTestCase): """ self._validate(expected, str(table)) - @skip("Needs to be further invstigated") def test_formatting_with_carriage_return_marker_3693_b(self): """ Testing of issue https://github.com/evennia/evennia/issues/3693 @@ -459,8 +443,8 @@ class TestEvTable(EvenniaTestCase): expected = """ | | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -| Welcome to your new Evennia-based game! Visit https://www.evennia.com if | -| you need help, want to contribute, report issues or just join the community. | +| Welcome to your new Evennia-based game! Visit https://www.evennia.com if you | +| need help, want to contribute, report issues or just join the community. | | | | As a privileged user, write batchcommand tutorial_world.build to build | | tutorial content. Once built, try intro for starting help and tutorial to |