diff options
| Commit | 672d531cc0b945b25ae00674fcaa75987243d945 (patch) | |
|---|---|---|
| Author | 2024-12-31 19:16:36 +0200 | |
| Committer | 2024-12-31 19:16:36 +0200 | |
| Files | accbe9d50934ef640cc5770679e19a99aad1f4d6 /single.awk | |
| csg-672d531cc0b945b25ae00674fcaa75987243d945.tar csg-672d531cc0b945b25ae00674fcaa75987243d945.tar.gz csg-672d531cc0b945b25ae00674fcaa75987243d945.zip | ||
| Parent | 3e59aced00958cc7d7b7f6b582ed46e91b01bfca (diff) | |
fix(single): Move automatic links below blockquotes and code blocks
1 files changed, 24 insertions, 24 deletions
| -rw-r--r-- | single.awk | 48 |
@@ -104,30 +104,6 @@ BEGIN { next } -# Automatic links -/<[^ \t<>]+>/ { - ## URL: <uri_scheme:...> - while (match($0, /<[A-Za-z][-A-Za-z0-9+.]*:[^ \t<>]+>/)) { - href = substr($0, RSTART + 1, RLENGTH - 2) - sub_match("<a href=\"" href "\">" href "</a>") - } - - ## 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("<a href=\"mailto:" href_masked "\">" href_masked "</a>") - } -} - # 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: <uri_scheme:...> + while (match($0, /<[A-Za-z][-A-Za-z0-9+.]*:[^ \t<>]+>/)) { + href = substr($0, RSTART + 1, RLENGTH - 2) + sub_match("<a href=\"" href "\">" href "</a>") + } + + ## 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("<a href=\"mailto:" href_masked "\">" href_masked "</a>") + } +} + # Line break / $/ { sub(/[ \t]* $/, "</br>") |
