#include #include #define BUFSIZE 4096 #define xmlput(n)\ for(pos = n; buf[pos] != '\n'; pos++) {\ switch(buf[pos]) {\ default: putchar(buf[pos]); break;\ case '>' : fputs(">",stdout); break;\ case '<' : fputs("<",stdout); break;\ case '&' : fputs("&",stdout); break;\ case '\'': fputs("'",stdout); break;\ case '"' : fputs(""",stdout); break;\ }\ } #define html(s) fputs(s,stdout) #define getbuf() fgets(buf,BUFSIZE,stdin) int main(void) { char buf[BUFSIZE]; int pos, list_state = 0; html( "\n" "\n" "\n" "\n" "\n" "\n" ); while (getbuf() != NULL) { if (!strncmp(buf,"###",3)) { html("

"); xmlput(4); html("

"); continue; } else if (!strncmp(buf,"##",2)) { html("

"); xmlput(3); html("

"); continue; } else if (buf[0] == '#') { html("

"); xmlput(2); html("

"); continue; } else if (buf[0] == '>') { fputs("
",stdout); xmlput(2); fputs("
\n",stdout); continue; } else if (buf[0] == '*') { if (list_state == 0) html("\n"); list_state = 0; continue; } else if (!strncmp(buf,"=>",2)) { html("

"); xmlput(pos); html("

\n"); continue; } else if (!strncmp(buf,"```",3)) { getbuf(); html("
");
			while (strncmp(buf,"```",3)) {
				xmlput(0); putchar('\n'); getbuf();
			} html("
\n"); continue; } html("

"); xmlput(0); html("

\n"); } html(""); html(""); }