From 019a9ea0097e148ba8b5d614827c37920c948ef1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sat, 20 May 2023 13:14:06 +0200 Subject: [PATCH] Extension: Arrows --- markdown.awk | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/markdown.awk b/markdown.awk index b507266..4e1dfa6 100755 --- a/markdown.awk +++ b/markdown.awk @@ -74,7 +74,7 @@ # - ? ... three-dot ellipsis (smartypants) # - [-] en-dash (smartypants) # - [ ] Automatic em-dash / en-dash -# - [ ] Automatic -> Arrows <- +# - [x] Automatic -> Arrows <- (custom) function debug(text) { printf "\n---\n%s\n---\n", text > "/dev/stderr"; } @@ -113,7 +113,7 @@ function inline( line, LOCAL, len, code, href, guard ) { if ( line ~ /^$/ ) { # Recursion End return ""; - # omit processing of escaped characters + # omit processing of escaped characters } else if ( line ~ /^\\[]\\`\*_\{\}\(\)#\+-\.![]/) { return substr(line, 2, 1) inline( substr(line, 3) ); @@ -286,6 +286,14 @@ function inline( line, LOCAL, len, code, href, guard ) { len = RLENGTH; return substr( line, 1, len ) inline(substr(line, len + 1)); + # Arrows + } else if ( line ~ /^-->( |$)/) { # ignore multidash-arrow + return "-->" inline( substr(line, 4) ); + } else if ( line ~ /^<-( |$)/) { + return "←" inline( substr(line, 3) ); + } else if ( line ~ /^->( |$)/) { + return "→" inline( substr(line, 3) ); + # Escape lone HTML character } else if ( match( line, /^[&<>"']/) ) { return HTML(substr(line, 1, 1)) inline(substr(line, 2)); -- 2.39.2