From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18403 invoked from network); 20 Dec 2020 09:30:55 -0000 Received: from ewsd.inri.net (107.191.116.128) by inbox.vuxu.org with ESMTPUTF8; 20 Dec 2020 09:30:55 -0000 Received: from asquith.prosimetrum.com ([125.236.209.157]) by ewsd; Sun Dec 20 04:28:26 -0500 2020 Message-ID: Date: Sun, 20 Dec 2020 22:29:12 +1300 From: umbraticus@prosimetrum.com To: 9front@9front.org MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: open ORM over XML reduce/map framework-oriented content-driven generator Subject: [9front] htmlfmt anchor corner cases Reply-To: 9front@9front.org Precedence: bulk With the -u flag, htmlfmt doesn't print relative links starting with a slash correctly: ; echo 'blah' | 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 '' | 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;