Minnor changes to wikifs/tohtml.c so it
generates more 'standard'(hah!) html
that can be styled thru css.
Also remove spaces from anchor names and other various fixes.
Notes:
Sat Oct 1 10:24:38 EDT 2005 rsc
patch/note wikifs-tohtml-improvements
I made the code a little clearer and made the new code
look like the old code. I'm kind of annoyed I had to
do the latter, since I wrote the wiki page about such
things at your behest, and then you didn't follow the
instructions. There were many strange spacings to go
around.
I also changed some things like
to
.
I can only assume you meant the latter, since to 8c,
is just
.
Russ
Reference: /n/sources/patch/applied/wikifs-tohtml-improvements
Date: Wed Sep 28 06:33:10 CES 2005
Reviewed-by: rsc
--- /sys/src/cmd/wikifs/tohtml.c Wed Sep 28 06:26:13 2005
+++ /sys/src/cmd/wikifs/tohtml.c Wed Sep 28 06:26:04 2005
@@ -180,8 +180,8 @@
String*
pagehtml(String *s, Wpage *wtxt, int ty)
{
- int inlist, inpre, inpara;
- char *p, tmp[40];
+ int inlist, inpre, inpara, t, tn;
+ char *p, *c, tmp[40];
Wpage *w;
inlist = 0;
@@ -189,49 +189,54 @@
inpara = 0;
for(w=wtxt; w; w=w->next){
- switch(w->type){
+ t = w->type;
+ tn = Whr; // This is the end
+ if(w->next)
+ tn = w->next->type;
+
+ if(inlist && !(t == Wbullet || t == Wlink || t == Wman || t == Wplain)){
+ inlist = 0;
+ s = s_append(s, "\n\n\n");
+ }
+ if(inpre && (t == Wheading || t == Wpara || t == Wbullet || t == Whr || t == Wplain)){
+ inpre = 0;
+ s = s_append(s, "\n");
+ }
+
+ switch(t){
case Wheading:
- /*
- if(!inpara){
- inpara = 1;
- s = s_append(s, "\n
\n");
- }
- */
- s = s_appendlist(s, "
\ntext,"\" />", w->text, "
\n", nil);
+ // a name='' can't contain spaces
+ p = strdup(w->text);
+ for(c = p; *c != '\0'; c++)
+ if(*c == ' ')
+ *c = '_';
+ s = s_appendlist(s, "\n
\n"); inpara = 1; - s = s_append(s, "\n
\n"); } + break; case Wbullet: - if(inpre){ - inpre = 0; - s = s_append(s, "\n"); - } - if(!inlist){ + if(!inlist) { inlist = 1; s = s_append(s, "\n
\n"); @@ -275,38 +271,20 @@ break; case Wplain: - if(inpre){ - inpre = 0; - s = s_append(s, "\n"); - } - if(inpara) - inpara = 0; s = s_escappend(s, w->text, 0); break; } } if(inlist) - s = s_append(s, "\n
\n"); + if(inpara) + s = s_append(s, "\n
\n"); return s; } static String* -grey(String *s) -{ - return s_append(s, ""); -} - -static String* -ungrey(String *s) -{ - return s_append(s, ""); -} - -static String* copythru(String *s, char **newp, int *nlinep, int l) { char *oq, *q, *r; @@ -402,17 +380,30 @@ n2 = atoi(q+1); else n2 = n1; - s = grey(s); + s = s_append(s,""); s = copythru(s, &pnew, &nline, n1-1); - s = ungrey(s); + s = s_append(s,""); s = copythru(s, &pnew, &nline, n2); + s = s_append(s,""); break; +/* + //This is not what we want... + case 'd': + n1 = atoi(q+1); + + s = s_append(s,"