diff options
author | Unknwon <u@gogs.io> | 2017-06-06 15:41:27 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-06-06 15:41:27 -0400 |
commit | a851b77ac9e5d95f71fb0e98cd134cd0e692f782 (patch) | |
tree | 3ed238d30773b379218e4259dcf49ca9180823e1 /templates/repo | |
parent | e9a2b72ddb0a5d069e72aceabb36337e5b9e9dcd (diff) |
markup: able to display image from IPython notebook (#4366)
Diffstat (limited to 'templates/repo')
-rw-r--r-- | templates/repo/view_file.tmpl | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index b8d6c1e4..dea9493e 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -42,7 +42,6 @@ {{else if .IsIPythonNotebook}} <script> var rendered = null; - console.log("fuck") $.getJSON("{{.RawFileLink}}", null, function(notebook_json) { var notebook = nb.parse(notebook_json); rendered = notebook.render(); @@ -52,8 +51,14 @@ hljs.highlightBlock(block); }); + // Overwrite image method to append proper prefix to the source URL + var renderer = new marked.Renderer(); + var context = '{{.TreeLink}}'.replace('/src/', '/raw/'); + renderer.image = function (href, title, text) { + return `<img src="${context}/${href}"` + } $("#ipython-notebook .nb-markdown-cell").each(function(i, markdown) { - $(markdown).html(marked($(markdown).html())); + $(markdown).html(marked($(markdown).html(), {renderer: renderer})); }); }); </script> |