#include #include #define BUFSIZE 4096 #define html(s) fputs(s,stdout) #define getbuf() fgets(buf,BUFSIZE,stdin) #define xmlput(n)\ for(pos = n; buf[pos] != '\n'; pos++) {\ switch(buf[pos]) {\ default: putchar(buf[pos]); break;\ case '>' : html(">"); break;\ case '<' : html("<"); break;\ case '&' : html("&"); break;\ case '\'': html("'"); break;\ case '"' : html("""); break;\ }\ } 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("

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

"); xmlput(3); html("

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

"); xmlput(2); html("

"); } else if (buf[0] == '>') { fputs("

",stdout); xmlput(2); fputs("

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

"); xmlput(pos+1); html("

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

"); xmlput(0); html("

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