From 672d531cc0b945b25ae00674fcaa75987243d945 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 31 Dec 2024 19:16:36 +0200 Subject: fix(single): Move automatic links below blockquotes and code blocks --- single.awk | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'single.awk') diff --git a/single.awk b/single.awk index 0add85e..69c9f32 100644 --- a/single.awk +++ b/single.awk @@ -104,30 +104,6 @@ BEGIN { next } -# Automatic links -/<[^ \t<>]+>/ { - ## URL: - while (match($0, /<[A-Za-z][-A-Za-z0-9+.]*:[^ \t<>]+>/)) { - href = substr($0, RSTART + 1, RLENGTH - 2) - sub_match("" href "") - } - - ## Email addresses, with support for quoted local part "..."@... - ## and ip address literal ...@[...] - while (match($0, /<([^ \t<>]+|".+")@([-A-Za-z0-9]+\.[^ \t<>]+|\[[0-9A-Fa-f.:]+\])>/)) { - href = substr($0, RSTART + 1, RLENGTH - 2) - href_masked = "" - ## The original markdown blogpost calls for convertions of all - ## email characters into their hex values. Allegedly, this fools - ## many autoharvesting spam bots. - for (i = length(href); i > 0; --i) { - href_masked = sprintf("&#x%X;", char_to_dec[char(href, i)]) href_masked - } - ## href="mailto:..." - sub_match("" href_masked "") - } -} - # Blockquotes blockquote_level > 0 && empty0 { for (P1 = P1 ORS; blockquote_level > 0; --blockquote_level) { @@ -172,6 +148,30 @@ inside_codeblock && ! /^[ \t]*$/ { emptyP1 = 1 } +# Automatic links +/<[^ \t<>]+>/ { + ## URL: + while (match($0, /<[A-Za-z][-A-Za-z0-9+.]*:[^ \t<>]+>/)) { + href = substr($0, RSTART + 1, RLENGTH - 2) + sub_match("" href "") + } + + ## Email addresses, with support for quoted local part "..."@... + ## and ip address literal ...@[...] + while (match($0, /<([^ \t<>]+|".+")@([-A-Za-z0-9]+\.[^ \t<>]+|\[[0-9A-Fa-f.:]+\])>/)) { + href = substr($0, RSTART + 1, RLENGTH - 2) + href_masked = "" + ## The original markdown blogpost calls for convertions of all + ## email characters into their hex values. Allegedly, this fools + ## many autoharvesting spam bots. + for (i = length(href); i > 0; --i) { + href_masked = sprintf("&#x%X;", char_to_dec[char(href, i)]) href_masked + } + ## href="mailto:..." + sub_match("" href_masked "") + } +} + # Line break / $/ { sub(/[ \t]* $/, "
") -- cgit v1.3.1-23-gd82d