From bf9ff78bcc856991dfe320932f114f7ef6252868 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 16 May 2020 02:19:45 +0200 Subject: [PATCH] autofill blank link descriptions --- copyparty/web/md.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/copyparty/web/md.js b/copyparty/web/md.js index a42155c1..3b69c3d4 100644 --- a/copyparty/web/md.js +++ b/copyparty/web/md.js @@ -150,8 +150,19 @@ function convert_markdown(md_text) { var md_html = marked(md_text); var md_dom = new DOMParser().parseFromString(md_html, "text/html").body; + var nodes = md_dom.getElementsByTagName('a'); + for (var a = nodes.length - 1; a >= 0; a--) { + var href = nodes[a].getAttribute('href'); + var txt = nodes[a].textContent; + + if (!txt) + nodes[a].textContent = href; + else if (href !== txt) + nodes[a].setAttribute('class', 'vis'); + } + // todo-lists (should probably be a marked extension) - var nodes = md_dom.getElementsByTagName('input'); + nodes = md_dom.getElementsByTagName('input'); for (var a = nodes.length - 1; a >= 0; a--) { var dom_box = nodes[a]; if (dom_box.getAttribute('type') !== 'checkbox')