mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
756 stars 138 forks source link

Valid HTML/XHTML #150

Closed geekdrive closed 3 years ago

geekdrive commented 3 years ago

Output valid XHTML5. Currently it won't properly display in a browser when using the correct XHTML mime or the .xhtml extension (which implies the mime).

--- md2html/md2html.c.orig      2020-09-30 10:44:48.000000000 +0100
+++ md2html/md2html.c   2021-02-09 13:57:35.082225253 +0000
@@ -152,7 +152,8 @@

     /* Write down the document in the HTML format. */
     if(want_fullhtml) {
-        fprintf(out, "<html>\n");
+        fprintf(out, "<!DOCTYPE html>\n");
+        fprintf(out, "<html%s>\n", want_xhtml ? " xmlns=\"http://www.w3.org/1999/xhtml\"" : "");
         fprintf(out, "<head>\n");
         fprintf(out, "<title></title>\n");
         fprintf(out, "<meta name=\"generator\" content=\"md2html\"%s>\n", want_xhtml ? " /" : "");

html.txt

mity commented 3 years ago

Fixed in a slightly more verbose way. Thanks for reporting it.