From bc9004305ebc36539b7b6a699b18b02c13f9ab48 Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Tue, 8 Sep 2020 13:15:43 -0500 Subject: add a stylesheet --- TODO.md | 1 + gemini.py | 12 ++++++------ style.css | 3 +++ 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 style.css diff --git a/TODO.md b/TODO.md index 837dd54..112487c 100644 --- a/TODO.md +++ b/TODO.md @@ -8,3 +8,4 @@ - [ ] search in page - [ ] work with search pages - [x] stdlib url parsing in gemini module + - [ ] nice typography diff --git a/gemini.py b/gemini.py index beb2d5c..9856449 100644 --- a/gemini.py +++ b/gemini.py @@ -8,6 +8,7 @@ def htmlescape(text: str) -> str: def gem2html(gem: str) -> str: html = [] + html.append(''.format(css=open('style.css').read())) state = 'text' blanklines = 0 for line in gem.split('\n'): @@ -50,12 +51,11 @@ def gem2html(gem: str) -> str: pass elif state == 'links': tokens = line.split(None, 2) - if len(tokens) == 3: - _, url, text = tokens - html.append('
  • {text}
  • '.format(url=url, text=text)) - else: - _, url = tokens - html.append('
  • {url}
  • '.format(url=url)) + url = tokens[1] + text = None if len(tokens) < 3 else tokens[2] + url_parts = urllib.parse.urlsplit(url) + external = ' class="external"' if url_parts.scheme not in ('gemini', '') else '' + html.append('{text}'.format(url=url, text=text or url, external=external)) elif state == 'list': html.append('
  • {}
  • '.format(line[2:])) elif state == 'pre': diff --git a/style.css b/style.css new file mode 100644 index 0000000..c4b8372 --- /dev/null +++ b/style.css @@ -0,0 +1,3 @@ +li.external a { + color: red; +} -- cgit v1.2.3