Wrap headings and links

This commit is contained in:
Callum Brown 2020-11-08 12:58:17 +00:00
parent 0b2792c2af
commit a8a0be4754
1 changed files with 5 additions and 3 deletions

View File

@ -913,13 +913,13 @@ you'll be able to transparently follow links to Gopherspace!""")
initial_indent = "> ", subsequent_indent="> ") + "\n")
elif line.startswith("###"):
line = line[3:].lstrip("\t ")
tmpf.write("\x1b[4m" + line + "\x1b[0m""\n")
tmpf.write("\x1b[4m" + textwrap.fill(line, self.options["width"]) + "\x1b[0m""\n")
elif line.startswith("##"):
line = line[2:].lstrip("\t ")
tmpf.write("\x1b[1m" + line + "\x1b[0m""\n")
tmpf.write("\x1b[1m" + textwrap.fill(line, self.options["width"]) + "\x1b[0m""\n")
elif line.startswith("#"):
line = line[1:].lstrip("\t ")
tmpf.write("\x1b[1m\x1b[4m" + line + "\x1b[0m""\n")
tmpf.write("\x1b[1m\x1b[4m" + textwrap.fill(line, self.options["width"]) + "\x1b[0m""\n")
else:
tmpf.write(textwrap.fill(line, self.options["width"]) + "\n")
tmpf.close()
@ -935,6 +935,8 @@ you'll be able to transparently follow links to Gopherspace!""")
def _format_geminiitem(self, index, gi, url=False):
protocol = "" if gi.scheme == "gemini" else " %s" % gi.scheme
line = "[%d%s] %s" % (index, protocol, gi.name or gi.url)
if gi.name:
line = textwrap.fill(line, self.options["width"], subsequent_indent=" ")
if gi.name and url:
line += " (%s)" % gi.url
return line