From 6a397234c5faed72683e833558883b2c0e04ebe9 Mon Sep 17 00:00:00 2001 From: Nicolas Sanchez Date: Tue, 28 Feb 2023 09:54:35 +0100 Subject: [PATCH] modif des liens pour supprimer tout formatage de l'url --- src/commons.rs | 3 +++ static/modules/md.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/commons.rs b/src/commons.rs index bf8b26e..27e29a8 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -22,4 +22,7 @@ impl Arguments { #[derive(Clone)] pub struct AppData { pub name: String, + pub db_url: String, + pub db_user: String, + pub db_passwd: String, } diff --git a/static/modules/md.js b/static/modules/md.js index e74c031..ad0d6bb 100644 --- a/static/modules/md.js +++ b/static/modules/md.js @@ -124,6 +124,11 @@ function formatLine(line) { let ret = removeMono(line); line = ret[0]; let listMono = ret[1]; + + // test remove link + ret = removeLink(line); + console.log('removeLink ' + ret[0]); + if (line.match(/^\s*-{3,}\s*$/)) { token = /^(\s*-{3,}\s*)$/ elem.classList.add('line'); @@ -454,6 +459,16 @@ function addMono(line, listMono) { return line; } +function removeLink(line) { + let listLink = line.match(/(\[([^\]]*?)\]\(([^\)]*?)\))/g); + if (listLink == null) { + return [line, null]; + } + + line = line.replace(/(\[([^\]]*?)\]\(([^\)]*?)\))/g, "[$2]()"); + return [line, listLink.reverse()]; +} + function addLink(line) { line = line.replace(/(\[([^\]]+?)\]\(([^\)]+?)\))/ig, '[$2]($3)'); line = line.replace(/(\[([^\]]+?)\]\(\))/ig, '[$2]()');