Markup handling improvements

This commit is contained in:
Mark Qvist
2025-12-30 12:16:24 +01:00
parent efd6285012
commit 237d56059d
2 changed files with 13 additions and 3 deletions

View File

@@ -1040,7 +1040,8 @@ class Browser:
fg = self.markup[fgpos+5:endpos]
self.page_foreground_color = fg
self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
try: self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
except Exception as e: self.attr_maps = [urwid.AttrMap(urwid.Text(f"Could not render page: {e}"), "inactive_text")]
self.response_progress = 0
self.response_speed = None
@@ -1107,7 +1108,8 @@ class Browser:
fg = self.markup[fgpos+5:endpos]
self.page_foreground_color = fg
self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
try: self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
except Exception as e: self.attr_maps = [urwid.AttrMap(urwid.Text(f"Could not render page: {e}"), "inactive_text")]
self.response_progress = 0
self.response_speed = None
@@ -1259,7 +1261,9 @@ class Browser:
fg = self.markup[fgpos+5:endpos]
self.page_foreground_color = fg
self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
try: self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
except Exception as e: self.attr_maps = [urwid.AttrMap(urwid.Text(f"Could not render page: {e}"), "inactive_text")]
self.response_progress = 0
self.response_speed = None
self.progress_updated_at = None

View File

@@ -146,6 +146,12 @@ def parse_line(line, state, url_delegate):
# Only parse content if not in literal state
if not state["literal"]:
# Apply markup sanitization
if first_char == ">" and "`<" in line:
# Remove heading status from lines containing fields
line = line.lstrip(">")
first_char = line[0]
# Check if the command is an escape
if first_char == "\\":
line = line[1:]