From: umbraticus@prosimetrum.com
To: 9front@9front.org
Subject: [9front] htmlfmt anchor corner cases
Date: Sun, 20 Dec 2020 22:29:12 +1300 [thread overview]
Message-ID: <D8CEA11CA85EF7900CB7856600279465@prosimetrum.com> (raw)
With the -u flag, htmlfmt doesn't print relative links starting with a
slash correctly:
; echo '<a href=/blah.html>blah</a>' |
htmlfmt -u http://site.dom/some/deep/path/index.html
blah [http://site.dom/some/deep/path/blah.html]
(should be http://site.dom/blah.html)
It also drops the space after “image” in the following example, since
the relative link starts with puntuation:
; echo '<img src=../blah.jpg>' | htmlfmt -a
[image../blah.jpg]
This messes up my elaborate rc + plumber webshit environment. To
address this one I just decided to go for {imgpath} instead of [image
imgpath] (also fixes the issue just illustrated by piping this
paragraph through fmt...) Patch below.
umbraticus
diff -r 1ae20c21a286 sys/src/cmd/htmlfmt/html.c
--- a/sys/src/cmd/htmlfmt/html.c Sat Dec 19 19:15:02 2020 +0100
+++ b/sys/src/cmd/htmlfmt/html.c Sun Dec 20 21:56:35 2020 +1300
@@ -170,6 +170,10 @@
if(base[strlen(base)-1]!='/' && (href==nil || href[0]!='/'))
result = eappend(result, "/", "");
free(base);
+ if(href!=nil && href[0]=='/'
+ && (base = strchr(result, ':')) != nil
+ && (base = strchr(base+3, '/')) != nil)
+ *base = '\0';
}
if(href){
if(result)
@@ -226,7 +230,7 @@
im = (Iimage*)il;
if(im->imsrc){
href = fullurl(u, im->imsrc);
- renderbytes(t, "[image %s]", href);
+ renderbytes(t, "{%s}", href);
free(href);
}
break;
next reply other threads:[~2020-12-20 9:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-20 9:29 umbraticus [this message]
2020-12-20 22:03 ` cinap_lenrek
2020-12-30 3:47 ` umbraticus
2020-12-31 9:42 ` umbraticus
2021-01-01 4:42 ` umbraticus
2021-01-01 10:05 ` Steve Simon
2021-01-01 19:26 ` ori
2021-01-20 2:20 ` ori
2021-01-20 2:49 ` Alex Musolino
2021-01-20 3:17 ` umbraticus
2021-01-24 5:46 ` umbraticus
2021-01-24 23:51 ` ori
2021-01-25 18:42 ` umbraticus
2021-01-27 2:42 ` ori
2021-08-28 20:22 ` Stuart Morrow
2021-08-29 1:52 ` umbraticus
2021-08-29 2:08 ` ori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D8CEA11CA85EF7900CB7856600279465@prosimetrum.com \
--to=umbraticus@prosimetrum.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).