diff --git a/Screenshot 2026-01-24 at 19.34.41.png b/Screenshot 2026-01-24 at 19.34.41.png new file mode 100644 index 0000000..e02b5d1 Binary files /dev/null and b/Screenshot 2026-01-24 at 19.34.41.png differ diff --git a/pyproject.toml b/pyproject.toml index 72e618c..2fd4f4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "textual-webterm" -version = "0.3.9" +version = "0.3.10" description = "Serve terminal sessions over the web" authors = ["Will McGugan "] license = "MIT" diff --git a/src/textual_webterm/svg_exporter.py b/src/textual_webterm/svg_exporter.py index d467284..6cbea18 100644 --- a/src/textual_webterm/svg_exporter.py +++ b/src/textual_webterm/svg_exporter.py @@ -222,13 +222,10 @@ def render_terminal_svg( if classes: attrs.append(f'class="{" ".join(classes)}"') - # For horizontal box-drawing spans, use textLength to ensure correct width - # This prevents gaps caused by font rendering of ─ being narrower than char_width - # Use "mostly" check to handle occasional corrupted chars (like U+FFFD) - if _is_mostly_horizontal_box_drawing(text) and len(text) > 1: - span_width = columns * char_width - attrs.append(f'textLength="{span_width:.1f}"') - attrs.append('lengthAdjust="spacing"') + # Note: textLength with lengthAdjust="spacing" was tried but causes + # visual positioning issues. The browser adds spacing between chars + # which shifts subsequent text visually even though x coords are correct. + # Accepting slight gaps in horizontal lines is preferable to cursor misalignment. parts.append(f'{_escape_xml(text)}') x += columns * char_width diff --git a/tests/test_svg_exporter.py b/tests/test_svg_exporter.py index 96e472c..c948b2c 100644 --- a/tests/test_svg_exporter.py +++ b/tests/test_svg_exporter.py @@ -829,8 +829,8 @@ class TestEdgeCases: assert "─" in svg assert "┐" in svg - def test_horizontal_lines_use_textlength(self) -> None: - """Horizontal line spans use textLength for correct width.""" + def test_horizontal_lines_render_without_textlength(self) -> None: + """Horizontal lines render without textLength (removed due to positioning issues).""" buffer = [[ self._char("╭"), self._char("─"), @@ -839,9 +839,11 @@ class TestEdgeCases: self._char("╮"), ]] svg = render_terminal_svg(buffer, width=5, height=1) - # Horizontal lines should have textLength attribute - assert 'textLength="24.0"' in svg - assert 'lengthAdjust="spacing"' in svg + # Horizontal lines should NOT have textLength (causes visual offset issues) + assert 'textLength=' not in svg + assert 'lengthAdjust=' not in svg + # But the characters should still be present + assert "─" in svg or "───" in svg def test_ansi_bright_colors(self) -> None: """All bright ANSI colors render."""