From: ori@eigenstate.org
To: 9front@9front.org
Subject: Re: [9front] htmlfmt anchor corner cases
Date: Fri, 01 Jan 2021 11:26:26 -0800 [thread overview]
Message-ID: <1D8FAB9003F85874A5FF46B50AC9CB99@eigenstate.org> (raw)
In-Reply-To: <49C417FFDD07DEE4E8B3A10933EE93B5@prosimetrum.com>
Quoth umbraticus@prosimetrum.com:
> Updated patch below (nimg should be global so
> subelements don't cause duplicate image
> footnotes). Quite enjoying these changes;
> footnote mode much easier to read and work with.
Yes, I like it quite a bit. And the number of '-'s
in the diff is a nice bonus too:
% diffstat /mail/fs/mbox/47572/body
+++ 120
--- 172
A couple of comments:
> + /* just a basic check... */
> + for(r = url; isalpha(*r); r++)
> + ;
> + if(r == baseurl || r[0] != ':' || r[1] != '/' || r[2] != '/' || r[3] == 0){
runestrncmp? directly indexing here without a length check makes me nervous,
and runestrncmp is more compact.
> - memset(rs, 0, sizeof rs);
> - if(regexec(urlprog, url, rs, nelem(rs)) == 0)
> - return nil;
> - base = estrdup(url);
> - slash = strrchr(base, '/');
> - if(slash!=nil && slash>=&base[rs[0].ep-rs[0].sp])
> - *slash = '\0';
> + for(r = path; isalpha(*r); r++)
> + ;
> + if(base == nil || r[0] == '#' || r > path && r[0] == ':' && r[1] == '/' && r[2] == '/' && r[3])
> + renderbytes(t, "%c%S%c", lc, path, rc);
> + else if(path[0] == '/')
> + renderbytes(t, "%c%S%S%c", lc, path[1] == '/' ? proto : root, path, rc);
same as above
> void
> @@ -195,7 +184,6 @@
> Anchor *a;
> Table *tab;
> Tablecell *cell;
> - char *href;
>
> inword = 0;
> col = 0;
> @@ -221,17 +209,18 @@
> renderbytes(t, "=======\n");
> break;
> case Iimagetag:
> - if(!aflag)
> + if(links == NONE)
> break;
> im = (Iimage*)il;
> if(im->imsrc){
> - href = fullurl(u, im->imsrc);
> - renderbytes(t, "[image %s]", href);
> - free(href);
> + if(links & FOOTNOTES)
You're using these as flags, but they don't act
like flags as far as I can tell?
I'd just use '==' here.
> void
> +afootnotes(URLwin *u, Bytes *t){
> + Anchor *x, *y, *z;
> +
> + x = u->docinfo->anchors;
> + if(x == nil)
> + return;
> + renderbytes(t, "\n\nlinks:\n");
> +
> + /* list needs reversing */
> + for(z = nil; x->next != nil; x = y){
> + y = x->next;
> + x->next = z;
> + z = x;
> + }
> + for(x->next = z; x != nil; x = x->next){
> + renderbytes(t, "[%d]", x->index);
> + renderurl(t, x->href, ' ', '\n');
> + };
> +}
Not a big deal, but why not just insert in the
right order in libhtml?
eg:
di->anchors = newanchor(++is->nanchors, name, href, target, di->anchors);
could become:
newanchor(di, ++is->nanchors, name, href, target);
which would do:
if(di->tail != nil)
di->tail->next = a;
di->tail = a;
Would probably simplify things if we can assume that anchors
are in the right order.
> ARGBEGIN{
> case 'a':
> - aflag++;
> + links |= INLINE;
> break;
> case 'c':
> defcharset = EARGF(usage());
> break;
> + case 'f':
> + links |= FOOTNOTES;
> + break;
Same comment about flags.
> case 'l': case 'w':
> err = EARGF(usage());
> width = atoi(err);
> @@ -65,8 +68,12 @@
> usage();
next prev parent reply other threads:[~2021-01-01 19:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-20 9:29 umbraticus
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 [this message]
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=1D8FAB9003F85874A5FF46B50AC9CB99@eigenstate.org \
--to=ori@eigenstate.org \
--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).