diff --git a/client/html/help_comments.tpl b/client/html/help_comments.tpl index a1a7b3db..6ba7e9f8 100644 --- a/client/html/help_comments.tpl +++ b/client/html/help_comments.tpl @@ -28,3 +28,11 @@ + +

You can also specify the size of embedded images like this:

+ + diff --git a/client/js/util/markdown.js b/client/js/util/markdown.js index f69df7c0..3d50b0d3 100644 --- a/client/js/util/markdown.js +++ b/client/js/util/markdown.js @@ -115,8 +115,37 @@ class StrikeThroughWrapper extends BaseMarkdownWrapper { } } -function formatMarkdown(text) { +function createRenderer() { + function sanitize(str) { + return str.replace(/&<"/g, function (m) { + if (m === '&') { + return '&'; + } + if (m === '<') { + return '<'; + } + return '"'; + }); + } + const renderer = new marked.Renderer(); + renderer.image = (href, title, alt) => { + let [_, url, width, height] = + /^(.+?)(?:\s=\s*(\d*)\s*x\s*(\d*)\s*)?$/.exec(href); + let res = '' + sanitize(alt);
+        if (width) {
+            res += ''; + } + return renderer; +} + +function formatMarkdown(text) { + const renderer = createRenderer(); const options = { renderer: renderer, breaks: true, @@ -145,7 +174,7 @@ function formatMarkdown(text) { } function formatInlineMarkdown(text) { - const renderer = new marked.Renderer(); + const renderer = createRenderer(); const options = { renderer: renderer, breaks: true,