xmlpage.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * xmlpage -- write a skeletal xhtml page
  3. *
  4. * Copyright (C) 2007 David L Parsons.
  5. * The redistribution terms are provided in the COPYRIGHT file that must
  6. * be distributed with this source code.
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <markdown.h>
  11. int
  12. mkd_xhtmlpage(Document *p, mkd_flag_t* flags, FILE *out)
  13. {
  14. char *title;
  15. extern char *mkd_doc_title(Document *);
  16. if ( mkd_compile(p, flags) ) {
  17. DO_OR_DIE( fprintf(out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
  18. "<!DOCTYPE html "
  19. " PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
  20. " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
  21. "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n") );
  22. DO_OR_DIE( fprintf(out, "<head>\n") );
  23. DO_OR_DIE( fprintf(out, "<title>") );
  24. if ( title = mkd_doc_title(p) ) {
  25. DO_OR_DIE( fprintf(out, "%s", title) );
  26. }
  27. DO_OR_DIE( fprintf(out, "</title>\n") );
  28. DO_OR_DIE( mkd_generatecss(p, out) );
  29. DO_OR_DIE( fprintf(out, "</head>\n"
  30. "<body>\n") );
  31. DO_OR_DIE( mkd_generatehtml(p, out) );
  32. DO_OR_DIE( fprintf(out, "</body>\n"
  33. "</html>\n") );
  34. return 0;
  35. }
  36. return EOF;
  37. }