From 05a63aa8654dbc95b2e739a3b77c5bb1df6bb04c Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Sun, 17 Oct 2021 12:23:23 -0500 Subject: lots of churn --- gemini.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'gemini.py') diff --git a/gemini.py b/gemini.py index c3ece46..560b01f 100644 --- a/gemini.py +++ b/gemini.py @@ -3,12 +3,15 @@ import socket import ssl import urllib.parse +import pyphen +dic = pyphen.Pyphen(lang='en_US') + def htmlescape(text: str) -> str: return text.replace('<', '<').replace('>', '>') def gem2html(gem: str) -> str: html = [] - html.append('\n') + html.append('\n\n
') state = 'text' blanklines = 0 for line in gem.split('\n'): @@ -62,14 +65,15 @@ def gem2html(gem: str) -> str: html.append(line) else: if line.startswith('###'): - html.append('

{}

'.format(line[3:].lstrip())) + html.append('

{}

'.format(line[3:].lstrip())) elif line.startswith('##'): - html.append('

{}

'.format(line[2:].lstrip())) + html.append('

{}

'.format(line[2:].lstrip())) elif line.startswith('#'): - html.append('

{}

'.format(line[1:].lstrip())) + html.append('

{}

'.format(line[1:].lstrip())) else: + ' '.join([dic.inserted(word, "\u00AD") for word in line.split()]) html.append('

{}

'.format(htmlescape(line))) - html.append('\n') + html.append('
\n\n') return '\n'.join(html) def urljoin(base: str, url: str) -> str: -- cgit v1.2.3