diff --git a/witchie/output.py b/witchie/output.py index 807b460..5306c6b 100644 --- a/witchie/output.py +++ b/witchie/output.py @@ -351,14 +351,31 @@ def print_status(status: Status, width: int = get_term_width(), padding: int = 0 def print_html(text, width=get_term_width(), padding=0): - first = True - for paragraph in html_to_paragraphs(text): - if not first: - print_out("│" * padding) - for line in paragraph: + is_in_pre = False + for line in html_to_paragraphs(text): + if line == '
': + print_out("│" * padding + "┌': + width += 1 + padding -= 1 + print_out("│" * padding + "└" + "─" * (width - 1)) + elif line == 'Quote " + "─" * (width - 6)) + width -= 1 + padding += 1 + elif line == '
': + print_out("│" * padding + "┌': + width += 1 + padding -= 1 + print_out("│" * padding + "└" + "─" * (width - 1)) + is_in_pre = False + elif is_in_pre: + print_out("│" * padding + line) + else: for subline in wc_wrap(line, width): print_out("│" * padding + subline) - first = False def print_poll(poll: Poll): diff --git a/witchie/utils/__init__.py b/witchie/utils/__init__.py index 64ceaf0..92fe5f6 100644 --- a/witchie/utils/__init__.py +++ b/witchie/utils/__init__.py @@ -39,6 +39,7 @@ class HTMLTextParser(HTMLParser): self.current_a = '' self.list_stack = deque() self.list_level = -1 + self.is_in_pre = False # for output self.links = [] @@ -48,8 +49,9 @@ class HTMLTextParser(HTMLParser): def commit(self): """Commit any dangling lines.""" - self.lines.append(self.line) - self.line = '' + if self.line != '': + self.lines.append(self.line) + self.line = '' def handle_starttag(self, tag, attrs): if tag in ('img', 'br', 'hr', 'wbr'): @@ -86,8 +88,15 @@ class HTMLTextParser(HTMLParser): self.line += 'Code " + "─" * (width - 5)) + width -= 1 + padding += 1 + is_in_pre = True + elif line == '