Summary Files Commits Branches @commit @diff @stats
path: root / single.awk
diff options
context:
space:
mode:
Commit672d531cc0b945b25ae00674fcaa75987243d945 (patch)
Author
 Syndamia <kamen@syndamia.com>
2024-12-31 19:16:36 +0200
Committer
 Syndamia <kamen@syndamia.com>
2024-12-31 19:16:36 +0200
Filesaccbe9d50934ef640cc5770679e19a99aad1f4d6 /single.awk
csg-672d531cc0b945b25ae00674fcaa75987243d945.tar
csg-672d531cc0b945b25ae00674fcaa75987243d945.tar.gz
csg-672d531cc0b945b25ae00674fcaa75987243d945.zip
Parent3e59aced00958cc7d7b7f6b582ed46e91b01bfca (diff)
fix(single): Move automatic links below blockquotes and code blocks
1 files changed, 24 insertions, 24 deletions
-rw-r--r--single.awk48
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: <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=\"&#x6D;&#x61;&#x69;&#x6C;&#x74;&#x6F;&#x3A;" 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=\"&#x6D;&#x61;&#x69;&#x6C;&#x74;&#x6F;&#x3A;" href_masked "\">" href_masked "</a>")
+ }
+}
+
# Line break
/ $/ {
sub(/[ \t]* $/, "</br>")