~edwargix/git.sr.ht

cceeb7f86f9c75d3aaba27bdc0e6b772e08c2b0d — Drew DeVault 5 years ago bc71f65
Fix images in rendered markdown in blob view
2 files changed, 13 insertions(+), 3 deletions(-)

M gitsrht/blueprints/repo.py
M gitsrht/templates/blob.html
M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +12 -2
@@ 223,14 223,24 @@ def tree(owner, repo, ref, path):
                        data = blob.data.decode()
                    except:
                        data = '[unable to decode]'
                markdown = not blob.is_binary and entry.name.endswith(".md")
                md = not blob.is_binary and entry.name.endswith(".md")
                if md:
                    link_prefix = url_for('repo.tree', owner=repo.owner,
                            repo=repo.name, ref=ref,
                            path=os.path.dirname("/".join(path)))
                    blob_prefix = url_for(
                        'repo.raw_blob', owner=repo.owner, repo=repo.name,
                        ref=ref, path=os.path.dirname("/".join(path)))
                    md = markdown(data, ["h1", "h2", "h3", "h4", "h5"],
                            link_prefix=[link_prefix, blob_prefix])
                    print(md)
                force_source = "view-source" in request.args
                return render_template("blob.html", view="blob",
                        owner=owner, repo=repo, ref=ref, path=path, entry=entry,
                        blob=blob, data=data, commit=orig_commit,
                        highlight_file=_highlight_file,
                        editorconfig=editorconfig,
                        markdown=markdown, force_source=force_source)
                        markdown=md, force_source=force_source)
            tree = git_repo.get(entry.id)

        if not tree:

M gitsrht/templates/blob.html => gitsrht/templates/blob.html +1 -1
@@ 89,7 89,7 @@ pre, body {
  <div class="row" style="margin-right: 0;">
    {% if markdown and not force_source %}
    <div class="col-md-10 offset-md-1" style="margin-top: 1rem">
      {{ data | extended_md }}
      {{ markdown }}
    </div>
    {% else %}
    {% if not blob.is_binary %}