From 967bea2aa7b2c11192632a1531a701a96820d51e Mon Sep 17 00:00:00 2001 From: Simon Marsh Date: Sun, 17 May 2020 10:05:25 +0100 Subject: [PATCH] Fix rendering of attributes that have trailing newlines --- StaticRoot/explorer.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/StaticRoot/explorer.js b/StaticRoot/explorer.js index 0cfef5f..a336e86 100644 --- a/StaticRoot/explorer.js +++ b/StaticRoot/explorer.js @@ -57,11 +57,29 @@ Vue.component('reg-attribute', { return reg[2] }, decorated: function() { - return anchorme(this.content.replace(/\n/g, "
"), { + var c = this.content + + // an attribute terminated with \n indicates a blank + // trailing line, however a single trailing
will + // not be rendered in HTML, this hack doubles up the + // trailing newline so it creates a
pair + // which renders as the blank line + if (c.substr(c.length-1) == "\n") { + c = c + "\n" + } + + // replace newlines with line breaks + c = c.replace(/\n/g, "
") + + // decorate + c = anchorme(c, { truncate: 40, ips: false, - attributes: [ { name: "target", value: "_blank" } ] + attributes: [ { name: "target", value: "_blank" } ] }) + + // and return the final decorated content + return c } } })