| 1 |
#include <stdio.h> |
| 2 |
/* bib2html.c. By Dennis Nicklaus [email protected], July 1998. |
| 3 |
Converts the bib.tex bibliography file output by the book-latex lifelines report |
| 4 |
into an HTML file, which is suitable for use as the bibliography file |
| 5 |
referenced by the HTML output of the html.dn report. |
| 6 |
|
| 7 |
Compile this simply as |
| 8 |
cc -o bib2html bib2html.c |
| 9 |
Then run it as a filter (assuming your file/database name is "dad"): |
| 10 |
bib2html < dad-bib.tex > dadbib.html |
| 11 |
|
| 12 |
|
| 13 |
Things will be a lot nicer if you first sort your bib.tex file by source |
| 14 |
number, something like: |
| 15 |
sort -n -t S -k 2 < dad-bib.tex > bibsort |
| 16 |
and then run it (bibsort) through bib2html |
| 17 |
|
| 18 |
This simple filter is by no means completely robust. You might have things |
| 19 |
in your bibliography that will confuse it. (Other LaTex commands, e.g.) |
| 20 |
It can handle {\em text} constructs, but that is about all. |
| 21 |
Ya' get what ya' pay for, I guess. |
| 22 |
*/ |
| 23 |
|
| 24 |
|
| 25 |
main() |
| 26 |
{ |
| 27 |
char c,word[80],*cptr; |
| 28 |
|
| 29 |
printf("<HTML>\n<DL>\n"); |
| 30 |
while ((c=getchar()) != EOF){ |
| 31 |
if (c== '\\'){ |
| 32 |
c=getchar(); |
| 33 |
if (c== 'b'){ /* then it is a new bibitem */ |
| 34 |
while ((c=getchar()) != '{'); /* go to bracket opening bibnumber */ |
| 35 |
cptr = word; |
| 36 |
while ((c=getchar()) != '}'){ |
| 37 |
*cptr =c; |
| 38 |
cptr++; |
| 39 |
} |
| 40 |
*cptr = '\0';/* end of bibitem name/number */ |
| 41 |
printf("\n<DT> <A NAME=\"%s\" ></A> <B> %s </B>",word,word); |
| 42 |
} |
| 43 |
else{ |
| 44 |
if (c== 'e'){ /* then it had better be \em */ |
| 45 |
c=getchar(); |
| 46 |
printf(" <I> "); |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
else if (c == '}') printf("</I>"); |
| 51 |
else if (c == '{'); /* ignore it */ |
| 52 |
else putchar(c); |
| 53 |
} |
| 54 |
printf("</DL>\n"); |
| 55 |
} |
| 56 |
|
| 57 |
|