9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] libhtml vs. <pre> tags
Date: Fri, 21 Oct 2005 08:19:38 -0500	[thread overview]
Message-ID: <20051021134702.0ACBB130256@dexter-peak.quanstro.net> (raw)
In-Reply-To: <32d987d50510202209h61161a7esb38c8dd5e4b635@mail.gmail.com>

okay, i was using htmlfmt to try to turn some <pre>-formatted
character tables into something useful. this is what i did:

rcsdiff html.c
===================================================================
RCS file: RCS/html.c,v
retrieving revision 1.1
diff -r1.1 html.c
84a85,100
> static void
> renderprerunes(Bytes* b, Rune* r)
> {
> 	char *s;
> 	int nr;
> 
> 	nr = r ? runestrlen(r) : 0;
> 	if (!nr)
> 		return;
> 	s = smprint("%.*S", runestrlen(r), r);
> 	growbytes(b, s, strlen(s));
> 	free(s);
> 	col = 0;			// just print it.
> 	inword = 0;
> }
> 
211c227,230
< 			renderrunes(t, it->s);
---
> 			if (il->state & IFwrap)
> 				renderrunes(t, it->s);
> 			else
> 				renderprerunes(t, it->s);

this does not fix the problem of converting \t → spaces
and "col = 0" in renderprerunes() is wrong. but it doesn't
look like col is reset when il->state == IFbrk or IFbrksp.

i still think this would be easier if everything inside
the <pre> were one token. that way we would know
when we would be done and be able to more easily/
accurately set the end state.

erik

Federico Benavento <benavento@gmail.com> writes

| 
| Now abaco handles <pre> text in a different way,
| this a quick and dirty change, since when the line
| width is bigger than the screen width the text is not
| showed. I knew that this was easy to fix, but I didn't
| because, right now, <table> is my problem.
| 
| cheers
| 
| On 10/21/05, Federico G. Benavento <benavento@gmail.com> wrote:
| > >in my hasty reading of libhtml i was thinking that the tokenization is almost
| > >correct. the only change needed is to not translate \t to 8 spaces. on output,
| >
| > I don't think this is needed since when there is a <pre> tag,
| > libhtml set the Item->flag to IFwrap, so this item should be treated
| > in a different way, this is what abaco should do.
| >
| > >for rendering, perhaps the solution is to add a flag indicating that the output
| > >is <pre>-formatted and just memcpy() the text in render.
| >
| > As I said the flag is already there, In my opinion libhtml is ok,
| > charon uses it (libhtml was a part of "I" web browser, which is a charon's translation
| > from limbo to c), what needs to be improved is abaco.
| >
| > >i was impressed with how little the tokenizing and rendering code was
| > >special cased, given how ad hoc html is. however, otoh, maybe <pre> should be
| > >handled in a special manner, with the tokenizer just converting character
| > >sets and entities and treating that result as one big Bytes*.
| >
| > cheers
| >
| > Federico G.Benavento


  parent reply	other threads:[~2005-10-21 13:19 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-21  4:34 Federico G. Benavento
2005-10-21  5:09 ` Federico Benavento
2005-10-21  9:49   ` Kenji Okamoto
2005-10-21  9:51     ` Kenji Okamoto
2005-10-21 13:19   ` erik quanstrom [this message]
2005-10-21 13:25   ` erik quanstrom
  -- strict thread matches above, loose matches on Subject: below --
2005-10-21 18:16 Trickey, Howard W (Howard)
2005-10-21 14:37 Federico G. Benavento
2005-10-21 14:21 Federico G. Benavento
2005-10-21 14:40 ` C H Forsyth
2005-10-21 14:02 Federico G. Benavento
2005-10-21 14:16 ` rog
2005-10-21 14:20   ` LiteStar numnums
2005-10-21 15:09   ` Wes Kussmaul
2005-10-21 13:47 Trickey, Howard W (Howard)
2005-10-21 13:55 ` erik quanstrom
2005-10-21 14:06 ` Wes Kussmaul
2005-10-21 14:16 ` C H Forsyth
2005-10-21 15:04 ` Uriel
2005-10-21 18:45   ` Wes Kussmaul
2005-10-21 19:12     ` Uriel
2005-10-21 19:20       ` Wes Kussmaul
2005-10-21 17:35 ` Skip Tavakkolian
2005-10-21 17:51   ` David Tolpin
2005-10-21 13:40 Federico G. Benavento
2005-10-21 13:51 ` erik quanstrom
2005-10-20  1:56 erik quanstrom
2005-10-20  2:17 ` erik quanstrom
2005-10-20 17:04   ` Federico Benavento
2005-10-21  4:01     ` erik quanstrom

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=20051021134702.0ACBB130256@dexter-peak.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@cse.psu.edu \
    /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).