summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgottox@rootkit.lan <gottox@rootkit.lan>2007-12-10 11:33:18 +0100
committergottox@rootkit.lan <gottox@rootkit.lan>2007-12-10 11:33:18 +0100
commitcd0b68c0b8bfbcbe22cb475e8875ad078baa5ae5 (patch)
tree8a1fd8d4dd2d08085c7234dae1183494eaa22e07
parentef4e3f0f54cac9fbe82fb3f26f4726fe67a10bfc (diff)
Add nohtml switch
-rw-r--r--cmarkdown.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/cmarkdown.c b/cmarkdown.c
index 9feb1d1..3c6b32a 100644
--- a/cmarkdown.c
+++ b/cmarkdown.c
@@ -54,7 +54,7 @@ Parser parsers[] = { dounderline, dolineprefix, dosurround, dolink, doreplace };
/* list of parsers */
FILE *source;
-unsigned int bsize = 0;
+unsigned int bsize = 0, nohtml = 0;
struct Tag lineprefix[] = {
{ " ", 0, "pre" },
{ "\t", 0, "pre" },
@@ -255,7 +255,10 @@ process(const char *begin, const char *end) {
for(i = 0; i < LENGTH(parsers) && affected == 0; i++)
affected = parsers[i](p, end);
if(affected == 0) {
- hprint(p,p+1);
+ if(nohtml)
+ hprint(p,p+1);
+ else
+ putchar(*p);
p++;
}
else
@@ -272,9 +275,12 @@ main(int argc, char *argv[]) {
if(argc > 1 && strcmp("-v", argv[1]) == 0)
eprint("markdown in C "VERSION" (C) Enno Boland\n");
else if(argc > 1 && strcmp("-h", argv[1]) == 0)
- eprint("Usage %s [file]\n",argv[0]);
- else if (argc > 1 && strcmp("-", argv[1]) != 0 && !(source = fopen(argv[1],"r")))
- eprint("Cannot open file `%s`\n",argv[1]);
+ eprint("Usage %s [-n] [file]\n -n escape html strictly\n",argv[0]);
+
+ if(argc > 1 && strcmp("-n", argv[1]) == 0)
+ nohtml = 1;
+ if(argc > 1 + nohtml && strcmp("-", argv[1 + nohtml]) != 0 && !(source = fopen(argv[1 + nohtml],"r")))
+ eprint("Cannot open file `%s`\n",argv[1 + nohtml]);
if(!(buffer = malloc(BUFFERSIZE)))
ERRMALLOC;
bsize = BUFFERSIZE;