Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/1001/1

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Cleaner HTML output.
 [rsc] --rw-rw-r-- M 667885 glenda sys 14527 Oct  1 11:13 sys/src/cmd/wikifs/tohtml.c
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/tohtml.c:177,187 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/tohtml.c:177,223
	  	return p;
	  }
	  
	+ int okayinlist[Nwtxt] =
	+ {
	+ 	[Wbullet]	1,
	+ 	[Wlink]	1,
	+ 	[Wman]	1,
	+ 	[Wplain]	1,
	+ };
	+ 
	+ int okayinpre[Nwtxt] =
	+ {
	+ 	[Wlink]	1,
	+ 	[Wman]	1,
	+ 	[Wpre]	1,
	+ };
	+ 
	+ int okayinpara[Nwtxt] =
	+ {
	+ 	[Wpara]	1,
	+ 	[Wlink]	1,
	+ 	[Wman]	1,
	+ 	[Wplain]	1,
	+ };
	+ 
	+ char*
	+ nospaces(char *s)
	+ {
	+ 	char *q;
	+ 	s = strdup(s);
	+ 	if(s == nil)
	+ 		return nil;
	+ 	for(q=s; *q; q++)
	+ 		if(*q == ' ')
	+ 			*q = '_';
	+ 	return s;
	+ }
	+ 	
	  String*
	  pagehtml(String *s, Wpage *wtxt, int ty)
	  {
	- 	int inlist, inpre, inpara;
	  	char *p, tmp[40];
	+ 	int inlist, inpara, inpre, t, tnext;
	  	Wpage *w;
	  
	  	inlist = 0;
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/tohtml.c:189,242 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/tohtml.c:225,278
	  	inpara = 0;
	  
	  	for(w=wtxt; w; w=w->next){
	- 		switch(w->type){
	+ 		t = w->type;
	+ 		tnext = Whr;
	+ 		if(w->next)
	+ 			tnext = w->next->type;
	+ 
	+ 		if(inlist && !okayinlist[t]){
	+ 			inlist = 0;
	+ 			s = s_append(s, "\n</li>\n</ul>\n");
	+ 		}
	+ 		if(inpre && !okayinpre[t]){
	+ 			inpre = 0;
	+ 			s = s_append(s, "</pre>\n");
	+ 		}
	+ 
	+ 		switch(t){
	  		case Wheading:
	- 			/*
	- 			if(!inpara){
	- 				inpara = 1;
	- 				s = s_append(s, "\n<p>\n");
	- 			}			
	- 			*/
	- 			s = s_appendlist(s, "<br />\n<a name=\"",w->text,"\" /><h3>", w->text, "</h3>\n", nil);
	+ 			p = nospaces(w->text);
	+ 			s = s_appendlist(s, 
	+ 				"\n<a name=\"", p, "\" /><h3>", 
	+ 				w->text, "</h3>\n", nil);
	+ 			free(p);
	  			break;
	  
	  		case Wpara:
	- 			if(inlist){
	- 				inlist = 0;
	- 				s = s_append(s, "\n</ul>\n");
	+ 			if(inpara){
	+ 				s = s_append(s, "\n</p>\n");
	+ 				inpara = 0;
	  			}
	- 			if(inpre){
	- 				inpre = 0;
	- 				s = s_append(s, "</pre>\n");
	- 			}
	- 			if(!inpara){
	+ 			if(okayinpara[tnext]){
	+ 				s = s_append(s, "\n<p class='para'>\n");
	  				inpara = 1;
	- 				s = s_append(s, "\n<p>\n");
	  			}
	  			break;
	  
	  		case Wbullet:
	- 			if(inpre){
	- 				inpre = 0;
	- 				s = s_append(s, "</pre>\n");
	- 			}
	  			if(!inlist){
	  				inlist = 1;
	  				s = s_append(s, "\n<ul>\n");
	- 			}
	- 			if(inpara)
	- 				inpara = 0;
	+ 			}else
	+ 				s = s_append(s, "\n</li>\n");
	  			s = s_append(s, "\n<li>\n");
	  			break;
	  
	  		case Wlink:
	- 			if(inpara)
	- 				inpara = 0;
	  			if(w->url == nil)
	  				p = mkurl(w->text, ty);
	  			else
	  				p = w->url;
	- 
	  			s = s_appendlist(s, "<a href=\"", p, "\">", nil);
	  			s = s_escappend(s, w->text, 0);
	  			s = s_append(s, "</a>");
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/tohtml.c:245,253 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/tohtml.c:281,286
	  			break;
	  
	  		case Wman:
	- 			if(inpara)
	- 				inpara = 0;
	- 			
	  			sprint(tmp, "%d", w->section);
	  			s = s_appendlist(s, 
	  				"<a href=\"http://plan9.bell-labs.com/magic/man2html/",
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/tohtml.c:256,267 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/tohtml.c:289,294
	  			break;
	  			
	  		case Wpre:
	- 			if(inpara)
	- 				inpara = 0;
	- 			if(inlist){
	- 				inlist = 0;
	- 				s = s_append(s, "\n</ul>\n");
	- 			}
	  			if(!inpre){
	  				inpre = 1;
	  				s = s_append(s, "\n<pre>\n");
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/tohtml.c:275,312 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/tohtml.c:302,321
	  			break;
	  
	  		case Wplain:
	- 			if(inpre){
	- 				inpre = 0;
	- 				s = s_append(s, "</pre>\n");
	- 			}
	- 			if(inpara)
	- 				inpara = 0;
	  			s = s_escappend(s, w->text, 0);
	  			break;
	  		}
	  	}
	  	if(inlist)
	- 		s = s_append(s, "\n</ul>\n");
	+ 		s = s_append(s, "\n</li>\n</ul>\n");
	  	if(inpre)
	  		s = s_append(s, "</pre>\n");
	- 	if(!inpara)
	- 		s = s_append(s, "\n<p>\n");
	+ 	if(inpara)
	+ 		s = s_append(s, "\n</p>\n");
	  	return s;
	  }
	  
	  static String*
	- grey(String *s)
	- {
	- 	return s_append(s, "<font color=#777777>");
	- }
	- 
	- static String*
	- ungrey(String *s)
	- {
	- 	return s_append(s, "</font>");
	- }
	- 
	- static String*
	  copythru(String *s, char **newp, int *nlinep, int l)
	  {
	  	char *oq, *q, *r;
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/tohtml.c:394,418 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/tohtml.c:403,429
	  			p[Blinelen(&b)-1] = '\0';
	  			if((q = strpbrk(p, "acd")) == nil)
	  				continue;
	+ 			n1 = atoi(q+1);
	+ 			if(q = strchr(q, ','))
	+ 				n2 = atoi(q+1);
	+ 			else
	+ 				n2 = n1;
	  			switch(*q){
	  			case 'a':
	  			case 'c':
	- 				n1 = atoi(q+1);
	- 				if(q = strchr(q, ','))
	- 					n2 = atoi(q+1);
	- 				else
	- 					n2 = n1;
	- 				s = grey(s);
	+ 				s = s_append(s, "<span class='old_text'>");
	  				s = copythru(s, &pnew, &nline, n1-1);
	- 				s = ungrey(s);
	+ 				s = s_append(s, "</span><span class='new_text'>");
	  				s = copythru(s, &pnew, &nline, n2);
	+ 				s = s_append(s, "</span>");
	  				break;
	  			}
	  		}
	  		close(fdiff);
	- 		s = grey(s);
	+ 		s = s_append(s, "<span class='old_text'>");
	  		s = s_append(s, pnew);
	- 		s = ungrey(s);
	+ 		s = s_append(s, "</span>");
	+ 
	  	}
	  	s_free(new);
	  	s_free(old);
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/tohtml.c:429,435 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/tohtml.c:440,446
	  	char *atime;
	  
	  	for(i=h->ndoc-1; i>=0; i--){
	- 		s = s_append(s, "<hr>\n");
	+ 		s = s_append(s, "<hr /><div class='diff_head'>\n");
	  		if(i==h->current)
	  			sprint(tmp, "index.html");
	  		else
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/tohtml.c:445,452 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/tohtml.c:456,463
	  			s = s_append(s, ", conflicting write");
	  		s = s_append(s, "\n");
	  		if(h->doc[i].comment)
	- 			s = s_appendlist(s, "<br><i>", h->doc[i].comment, "</i>\n", nil);
	- 		s = s_append(s, "<br><hr>");
	+ 			s = s_appendlist(s, "<br /><i>", h->doc[i].comment, "</i>\n", nil);
	+ 		s = s_append(s, "</div><hr />");
	  		s = s_diff(s, h, i, i-1);
	  	}
	  	s = s_append(s, "<hr>");
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/tohtml.c:564,570 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/tohtml.c:575,581
	  			break;
	  		x = e; l=LINELEN;
	  		while(l--)
	- 			x+=chartorune(&r,x);
	+ 			x+=chartorune(&r, x);
	  		x = strchr(x, ' ');
	  		if(x){
	  			*x = '\0';
 [rsc] --rw-rw-r-- M 667885 glenda sys 916 Oct  1 10:22 sys/src/cmd/wikifs/wiki2html.c
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/wiki2html.c:10,16 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/wiki2html.c:10,16
	  void
	  usage(void)
	  {
	- 	fprint(2, "usage: wiki2html [-d dir] wikifile\n");
	+ 	fprint(2, "usage: wiki2html [-hoDP ] [-d dir] wikifile\n");
	  	exits("usage");
	  }
	  
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/wiki2html.c:18,23 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/wiki2html.c:18,24
	  main(int argc, char **argv)
	  {
	  	int t;
	+ 	int parse;
	  	String *h;
	  	Whist *doc;
	  
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/wiki2html.c:39,44 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/wiki2html.c:40,47
	  	case 'D':
	  		t = Tdiff;
	  		break;
	+ 	case 'P':
	+ 		parse = 1;
	  	}ARGEND
	  
	  	if(argc != 1)
	/n/sourcesdump/2005/1001/plan9/sys/src/cmd/wikifs/wiki2html.c:52,57 - 
	/n/sourcesdump/2005/1002/plan9/sys/src/cmd/wikifs/wiki2html.c:55,64
	  	if(doc == nil)
	  		sysfatal("doc: %r");
	  
	+ 	if(parse){
	+ 		printpage(doc->doc->wtxt);
	+ 		exits(0);
	+ 	}
	  	if((h = tohtml(doc, doc->doc+doc->ndoc-1, t)) == nil)
	  		sysfatal("wiki2html: %r");
	  
 [rsc] --rw-rw-r-- M 667885 glenda sys 14527 Oct  1 11:13 sys/src/cmd/wikifs/tohtml.c
 [sys] --rwxrwxr-x M 667885 glenda sys 202486 Oct  1 23:08 386/bin/wikifs
	/sys/src/cmd/wikifs/tohtml.c:diffhtml
	/sys/src/cmd/wikifs/tohtml.c:doctext
	/sys/src/cmd/wikifs/tohtml.c:dodiff
	/sys/src/cmd/wikifs/tohtml.c:grey
	/sys/src/cmd/wikifs/tohtml.c:historyhtml
	/sys/src/cmd/wikifs/tohtml.c:historytext
	/sys/src/cmd/wikifs/tohtml.c:nospaces
	/sys/src/cmd/wikifs/tohtml.c:pagehtml
	/sys/src/cmd/wikifs/tohtml.c:pagetext
	/sys/src/cmd/wikifs/tohtml.c:s_appendbrk
	/sys/src/cmd/wikifs/tohtml.c:s_diff
	/sys/src/cmd/wikifs/tohtml.c:s_endline
	/sys/src/cmd/wikifs/tohtml.c:tohtml
	/sys/src/cmd/wikifs/tohtml.c:totext
	/sys/src/cmd/wikifs/tohtml.c:ungrey


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].