File indexing completed on 2024-04-28 11:21:10

0001 /*
0002  * xmlpage -- write a skeletal xhtml page
0003  *
0004  * Copyright (C) 2007 David L Parsons.
0005  * The redistribution terms are provided in the COPYRIGHT file that must
0006  * be distributed with this source code.
0007  */
0008 #include <stdio.h>
0009 #include <stdlib.h>
0010 #include <markdown.h>
0011 
0012 
0013 int
0014 mkd_xhtmlpage(Document *p, mkd_flag_t flags, FILE *out)
0015 {
0016     char *title;
0017     extern char *mkd_doc_title(Document *);
0018     
0019     if ( mkd_compile(p, flags) ) {
0020     DO_OR_DIE( fprintf(out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
0021                 "<!DOCTYPE html "
0022                 " PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
0023                 " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
0024                 "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n") );
0025 
0026     DO_OR_DIE( fprintf(out, "<head>\n") );
0027     DO_OR_DIE( fprintf(out, "<title>") );
0028     if ( title = mkd_doc_title(p) ) {
0029         DO_OR_DIE( fprintf(out, "%s", title) );
0030     }
0031     DO_OR_DIE( fprintf(out, "</title>\n") );
0032     DO_OR_DIE( mkd_generatecss(p, out) );
0033     DO_OR_DIE( fprintf(out, "</head>\n"
0034                 "<body>\n") );
0035     
0036     DO_OR_DIE( mkd_generatehtml(p, out) );
0037     DO_OR_DIE( fprintf(out, "</body>\n"
0038                 "</html>\n") );
0039 
0040     return 0;
0041     }
0042     return EOF;
0043 }