--- a/ChangeLog Sun May 17 02:32:02 2020 -0500
+++ b/ChangeLog Sun May 17 02:41:51 2020 -0500
@@ -1,3 +1,7 @@
+ * Switched to mistune for markdown rendering to fix images. Fixes * Always make the line numbers available in the diff template.
--- a/setup.py Sun May 17 02:32:02 2020 -0500
+++ b/setup.py Sun May 17 02:41:51 2020 -0500
@@ -3,7 +3,7 @@
author_email='grim@reaperworld.com',
url='https://keep.imfreedom.org/grim/hgwebplus',
@@ -15,7 +15,7 @@
package_data={'mercurial.templates': ['static/*']},
# skip mercurial because it might be installed on the system
--- a/src/hgwebplus.py Sun May 17 02:32:02 2020 -0500
+++ b/src/hgwebplus.py Sun May 17 02:41:51 2020 -0500
@@ -31,7 +31,7 @@
from mercurial.hgweb import webutil, hgweb_mod
from mercurial.hgweb.common import paritygen
templatefilter = registrar.templatefilter(filters)
@@ -249,6 +249,12 @@
ctx = context.resource(mapping, b'ctx')
+ class Renderer(mistune.Renderer): + def image(self, src, title, alt_text): + real_src = 'rawfile/%s/%s' % (ctx.rev(), src) + real_title = title or '' + return '<img src="%s" alt="%s">%s</img>' % (real_src, alt_text, real_title) # we iterate the files instead of a fileset, because we want to
# deterministically render readmes in the same order if there are more
# than one in a repository. With the fileset, we'd have to run through
@@ -258,7 +264,7 @@
if lower in [b'readme.txt', b'readme', b'readme.md']:
raw_utf8 = ctx[filename].data().decode('utf-8')
- return cmarkgfm.markdown_to_html(raw_utf8).encode('utf-8')
+ return mistune.markdown(raw_utf8, renderer=Renderer()).encode('utf-8')