Commit 59c0f9d88cdd78f718fca44638dffb31ada0c2a1
Abstract converting to HTML
Make and use a new function in common.py that converts markup to HTML, so that I can later add processing other than just `marko.convert`.Grey Nicholson committed on 5/15/2022, 5:29:21 PM
Parent: b9e674f6a58e57b2bb9df216b779c9375cca9957
Files changed
generator/common.py | changed |
generator/templates/entry.py | changed |
generator/common.py | ||
---|---|---|
@@ -46,9 +46,9 @@ | ||
46 | 46 … | ) |
47 | 47 … | ) |
48 | 48 … | + '<content type="html">' |
49 | 49 … | + "\n" |
50 | - + print_html_escaped(marko.convert(entries[id].content)) | |
50 … | + + print_html_escaped(convert_to_html(entries[id].content)) | |
51 | 51 … | + "</content>" |
52 | 52 … | + "</entry>" |
53 | 53 … | ) |
54 | 54 … | |
@@ -57,8 +57,12 @@ | ||
57 | 57 … | |
58 | 58 … | colour_class = f"month-{list(reversed(months))[0].month:02d}" |
59 | 59 … | |
60 | 60 … | |
61 … | +def convert_to_html(hypertext): | |
62 … | + return marko.convert(hypertext) | |
63 … | + | |
64 … | + | |
61 | 65 … | def entries_in_series(series): |
62 | 66 … | return dict( |
63 | 67 … | [ |
64 | 68 … | (id, entries[id]) |
generator/templates/entry.py | ||
---|---|---|
@@ -1,6 +1,4 @@ | ||
1 | -import marko | |
2 | - | |
3 | 1 … | import common |
4 | 2 … | |
5 | 3 … | |
6 | 4 … | def links_to_nearby_entries(id): |
@@ -168,9 +166,13 @@ | ||
168 | 166 … | if "series" in entry |
169 | 167 … | else "" |
170 | 168 … | ) |
171 | 169 … | description = ( |
172 | - ('<div class="description">' + marko.convert(entry["description"]) + "</div>") | |
170 … | + ( | |
171 … | + '<div class="description">' | |
172 … | + + common.convert_to_html(entry["description"]) | |
173 … | + + "</div>" | |
174 … | + ) | |
173 | 175 … | if "description" in entry |
174 | 176 … | else "" |
175 | 177 … | ) |
176 | 178 … | entry_links = ( |
@@ -236,9 +238,9 @@ | ||
236 | 238 … | </header> |
237 | 239 … | <main> |
238 | 240 … | <hr/> |
239 | 241 … | <section> |
240 | - {marko.convert(entry.content)} | |
242 … | + {common.convert_to_html(entry.content)} | |
241 | 243 … | </section> |
242 | 244 … | <footer> |
243 | 245 … | <hr/> |
244 | 246 … | <section> |
Built with git-ssb-web