From 9b019ee3d845d1edac5a6a33ebf385b120f136f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sat, 31 Aug 2024 19:24:38 +0200 Subject: [PATCH] simpler reex for matching email links (again, for portability ) --- markdown.awk | 2 +- tests-markdown.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/markdown.awk b/markdown.awk index 6e1440c..ad8c438 100755 --- a/markdown.awk +++ b/markdown.awk @@ -175,7 +175,7 @@ function inline( line, LOCAL, len, text, code, href, guard, ret ) { # quick link email # } else if ( match( line, /^<[a-zA-Z0-9.!#$%&'\''*+\/=?^_`{|}~-]+@[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*>/ ) ) { - } else if ( match( line, /^<[a-zA-Z0-9.!#$%&'\''*+\/=?^_`{|}~-]+@[a-zA-Z0-9]([a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-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-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9-]?[a-zA-Z0-9])?)*>/ ) ) { + } else if ( match( line, /^<[a-zA-Z0-9.!#$%&'\''*+\/=?^_`{|}~-]+@([a-zA-Z0-9]\.[a-zA-Z0-9]|[a-zA-Z0-9-])+>/ ) ) { len = RLENGTH; href = HTML( substr( line, 2, len - 2) ); ret = ret "" href ""; line = substr( line, len + 1); diff --git a/tests-markdown.sh b/tests-markdown.sh index 2bbcf5d..a834391 100755 --- a/tests-markdown.sh +++ b/tests-markdown.sh @@ -80,6 +80,9 @@ assert '' "

htt assert '' "

http://de.wikipedia.org

" "automatic link" # assert '' "

http://de.wikipedia.org

" "automatic link" +assert '' "

hello&goodbye@sub-test.example.com

" "automatic link, email" +# assert '' "

hällö&guttbei@sub-test.example.com

" "automatic link, email" + # Inline Links assert '[Wikipedia](http://de.wikipedia.org)' "

Wikipedia

" "inline link" assert '[Wikipedia](http://de.wikipedia.org "Online Encyclopedia")' "

Wikipedia

" "inline link" -- 2.39.2