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 | |
parent | e9a2b72ddb0a5d069e72aceabb36337e5b9e9dcd (diff) |
markup: able to display image from IPython notebook (#4366)
Diffstat (limited to 'templates')
-rw-r--r-- | templates/.VERSION | 2 | ||||
-rw-r--r-- | templates/repo/view_file.tmpl | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/templates/.VERSION b/templates/.VERSION index 250a5040..08cfb8f7 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.11.16.0605
\ No newline at end of file +0.11.17.0606
\ No newline at end of file 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> |