File: bib2html.c

package info (click to toggle)
lifelines 3.0.50-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 11,140 kB
  • ctags: 6,517
  • sloc: ansic: 57,468; xml: 8,014; sh: 4,255; makefile: 848; yacc: 601; perl: 170; sed: 16
file content (57 lines) | stat: -rw-r--r-- 1,644 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
/* bib2html.c.  By Dennis Nicklaus nicklaus@fnal.gov, July 1998.
   Converts the bib.tex bibliography file output by the book-latex lifelines report
   into an HTML file, which is suitable for use as the bibliography file
   referenced by the HTML output of the html.dn report.
   
   Compile this simply as 
          cc -o bib2html bib2html.c
   Then run it as a filter (assuming your file/database name is "dad"):
          bib2html < dad-bib.tex > dadbib.html
   

   Things will be a lot nicer if you first sort your bib.tex file by source
   number, something like:
          sort -n -t S -k 2 < dad-bib.tex > bibsort
   and then run it (bibsort) through bib2html

   This simple filter is by no means completely robust.  You might have things
   in your bibliography that will confuse it. (Other LaTex commands, e.g.)
   It can handle {\em text} constructs, but that is about all.
   Ya' get what ya' pay for, I guess.
*/	


main()
{
  char c,word[80],*cptr;

  printf("<HTML>\n<DL>\n");
  while ((c=getchar()) != EOF){
    if (c== '\\'){
      c=getchar();
      if (c== 'b'){ /* then it is a new bibitem */
	while ((c=getchar()) != '{'); /* go to bracket opening bibnumber */
	cptr = word;
	while ((c=getchar()) != '}'){ 
	  *cptr =c;
	  cptr++;
	}
	*cptr = '\0';/* end of bibitem name/number */
	printf("\n<DT> <A NAME=\"%s\" ></A> <B> %s </B>",word,word);
      }
      else{
	if (c== 'e'){ /* then it had better be \em */
	  c=getchar();
	  printf(" <I> ");
	}
      }
    }
    else if (c == '}') 	  printf("</I>");
    else if (c == '{'); /* ignore it */
    else putchar(c);
  }
  printf("</DL>\n");
}