mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Fix broken Evtable formatting with MXP links. Resolve 3082
This commit is contained in:
parent
172d5162f0
commit
0c13cb3a9d
3 changed files with 13 additions and 22 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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 |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue