From 95dface9e7cd2956d0fd4a9b9041fca61afa4fe5 Mon Sep 17 00:00:00 2001
From: jwansek <eddie.atten.ea29@gmail.com>
Date: Sun, 18 Apr 2021 16:04:17 +0100
Subject: added linking to markdown images

---
 parser.py               |  6 +++++-
 templates/thoughts.html | 14 +++++++-------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/parser.py b/parser.py
index 1ba94cd..9071a11 100755
--- a/parser.py
+++ b/parser.py
@@ -33,9 +33,13 @@ class HighlighterRenderer(misaka.SaferHtmlRenderer):
         out = '\n<blockquote>'
         for line in houdini.escape_html(content.strip()).split("\n"):
             out += '\n<span class="quote">{}</span><br>'.format(line)
-        print(out)
         return out + '\n</blockquote>'
 
+    def image(self, link, title, alt):
+        return "<a href='%s' target='_blank'><img alt='%s' src='%s'></a>" % (
+            urlparse(link)._replace(query='').geturl(), alt, link
+        )
+
 def get_thought_from_id(db, id_):
     category_name, title, dt, markdown = db.get_thought(id_)
     return category_name, title, dt, parse_text(markdown)
diff --git a/templates/thoughts.html b/templates/thoughts.html
index 0d768e4..bdbe854 100644
--- a/templates/thoughts.html
+++ b/templates/thoughts.html
@@ -1,12 +1,12 @@
 {% extends "template.html" %}
 {% block content %}
     {% for category_name, thoughts in tree.items() %}
-    <h2 id={{category_name.replace(' ', '_')}}>{{category_name}}</h2>
-    <dl>
-        {% for id_, title, dt in thoughts %}
-        <dt><a href={{'/thought?id=%i' % id_}}>{{title}}</a></dt>
-        <dd>{{dt}}</dd>
-        {% endfor %}
-    </dl>
+        <h3 id="{{category_name.replace(' ', '_')}}">{{category_name}}</h3>
+        <dl>
+            {% for id_, title, dt in thoughts %}
+                <dt><a href="{{'/thought?id=%i' % id_}}">{{title}}</a></dt>
+                <dd>{{dt}}</dd>
+            {% endfor %}
+        </dl>
     {% endfor %}
 {% endblock %}
\ No newline at end of file
-- 
cgit v1.2.3