fix: code block
This commit is contained in:
parent
784cc4f96d
commit
9d95431809
|
@ -75,10 +75,15 @@ class Item(Gtk.Box):
|
||||||
self.convert_content_to_pango()
|
self.convert_content_to_pango()
|
||||||
|
|
||||||
result = ""
|
result = ""
|
||||||
|
is_code = False
|
||||||
for line in self.content_markup:
|
for line in self.content_markup:
|
||||||
if isinstance(line, str):
|
if "<tt></tt>`" in line.strip():
|
||||||
result += f"{line}\n"
|
if is_code:
|
||||||
else: # code
|
is_code = False
|
||||||
|
else:
|
||||||
|
is_code = True
|
||||||
|
continue
|
||||||
|
if is_code or not isinstance(line, str):
|
||||||
label = Gtk.Label()
|
label = Gtk.Label()
|
||||||
label.set_use_markup(True)
|
label.set_use_markup(True)
|
||||||
label.set_wrap(True)
|
label.set_wrap(True)
|
||||||
|
@ -91,10 +96,16 @@ class Item(Gtk.Box):
|
||||||
label.set_halign(Gtk.Align.START)
|
label.set_halign(Gtk.Align.START)
|
||||||
self.content.append(label)
|
self.content.append(label)
|
||||||
|
|
||||||
result = "\n".join(line)
|
if not isinstance(line, str):
|
||||||
|
result = "\n".join(line.strip())
|
||||||
|
else:
|
||||||
|
result = line.strip()
|
||||||
|
|
||||||
self.content.append(CodeBlock(result))
|
self.content.append(CodeBlock(result))
|
||||||
result = ""
|
result = ""
|
||||||
|
else:
|
||||||
|
result += f"{line}\n"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not result.strip() == "<tt></tt>`":
|
if not result.strip() == "<tt></tt>`":
|
||||||
label = Gtk.Label()
|
label = Gtk.Label()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user