katdown

Un traducteur md -> html minimal en awk - retour accueil

git clone git://bebou.netlib.re/katdown
Log | Files | Refs | README |

commit a469c41b35be1593f6074b11ce98888ad2db4436
parent ae44c2fd6ba1788d5dbcab3f9d48deec068d67d3
Auteurice: Graham Marlow <graham@mgmarlow.com>
Date:   Fri,  8 Mar 2024 09:39:49 -0800

Fix links

Diffstat:
Mawkdown.awk | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/awkdown.awk b/awkdown.awk @@ -51,10 +51,11 @@ function render(line) { gsub(/\*(.*)\*/, sprintf("<strong>%s</strong>", substr(line, RSTART+1, RLENGTH-2)), line) } -# if (match(line, /(.*)\[(.+)\]\((.+)\)(.*)/, pats)) { -# gsub(/(.*)\[(.+)\]\((.+)\)(.*)/, -# sprintf("%s<a href='%s'>%s</a>%s", pats[1], pats[3], pats[2], pats[4]), line) -# } + if (match(line, /\[.+\]\(.+\)/)) { + inner = substr(line, RSTART+1, RLENGTH-2) + split(inner, spl, /\]\(/) + gsub(/\[.+\]\(.+\)/, sprintf("<a href=\"%s\">%s</a>", spl[2], spl[1]), line) + } return line }