diff --git a/Makefile b/Makefile index 6c808e9..7494543 100644 --- a/Makefile +++ b/Makefile @@ -32,10 +32,10 @@ libhoedown.a: $(HOEDOWN_SRC) # Executables -hoedown: examples/hoedown.o $(HOEDOWN_SRC) +hoedown: bin/hoedown.o $(HOEDOWN_SRC) $(CC) $(LDFLAGS) $^ -o $@ -smartypants: examples/smartypants.o $(HOEDOWN_SRC) +smartypants: bin/smartypants.o $(HOEDOWN_SRC) $(CC) $(LDFLAGS) $^ -o $@ # Perfect hashing @@ -55,7 +55,7 @@ test-pl: hoedown # Housekeeping clean: - $(RM) src/*.o examples/*.o + $(RM) src/*.o bin/*.o $(RM) libhoedown.so libhoedown.so.1 libhoedown.a $(RM) hoedown smartypants hoedown.exe smartypants.exe diff --git a/Makefile.win b/Makefile.win index a28326b..cda24b9 100644 --- a/Makefile.win +++ b/Makefile.win @@ -17,11 +17,11 @@ all: hoedown.dll hoedown.exe smartypants.exe hoedown.dll: $(HOEDOWN_SRC) hoedown.def $(CC) $(HOEDOWN_SRC) hoedown.def /link /DLL $(LDFLAGS) /out:$@ -hoedown.exe: examples\hoedown.obj $(HOEDOWN_SRC) - $(CC) examples\hoedown.obj $(HOEDOWN_SRC) /link $(LDFLAGS) /out:$@ +hoedown.exe: bin\hoedown.obj $(HOEDOWN_SRC) + $(CC) bin\hoedown.obj $(HOEDOWN_SRC) /link $(LDFLAGS) /out:$@ -smartypants.exe: examples\smartypants.obj $(HOEDOWN_SRC) - $(CC) examples\smartypants.obj $(HOEDOWN_SRC) /link $(LDFLAGS) /out:$@ +smartypants.exe: bin\smartypants.obj $(HOEDOWN_SRC) + $(CC) bin\smartypants.obj $(HOEDOWN_SRC) /link $(LDFLAGS) /out:$@ # Housekeeping diff --git a/bin/common.h b/bin/common.h new file mode 100644 index 0000000..9074bd6 --- /dev/null +++ b/bin/common.h @@ -0,0 +1,45 @@ +#include "version.h" + +#include +#include +#include +#include + +#define str(x) __str(x) +#define __str(x) #x + +#define count_of(arr) (sizeof(arr)/sizeof(0[arr])) + +int +parseint(const char *string, long *result) { + char *end; + errno = 0; + *result = strtol(string, &end, 10); + return !(*end || errno); +} + +const char * +strprefix(const char *str, const char *prefix) { + while (*prefix) { + if (!(*str && *str == *prefix)) return 0; + prefix++; str++; + } + return str; +} + +void +print_option(char short_opt, const char *long_opt, const char *description) { + if (short_opt) + printf(" -%c, ", short_opt); + else + printf(" "); + + printf("--%-13s %s\n", long_opt, description); +} + +void +print_version() { + int major, minor, revision; + hoedown_version(&major, &minor, &revision); + printf("Built with Hoedown v%d.%d.%d.\n", major, minor, revision); +} diff --git a/bin/hoedown.c b/bin/hoedown.c new file mode 100644 index 0000000..960bb3e --- /dev/null +++ b/bin/hoedown.c @@ -0,0 +1,502 @@ +#include "document.h" +#include "html.h" + +#include "common.h" +//#include + +/* NULL RENDERER */ + +enum renderer_type { + RENDERER_HTML, + RENDERER_HTML_TOC, + RENDERER_NULL, +}; + +hoedown_renderer * +null_renderer_new() { + hoedown_renderer *rend = malloc(sizeof(hoedown_renderer)); + if (rend) + memset(rend, 0x00, sizeof(hoedown_renderer)); + return rend; +} + +void +null_renderer_free(hoedown_renderer *rend) { + free(rend); +} + + +/* FEATURES INFO / DEFAULTS */ + +struct extension_category_info { + unsigned int flags; + const char *option_name; + const char *label; +}; + +struct extension_info { + unsigned int flag; + const char *option_name; + const char *description; +}; + +struct html_flag_info { + unsigned int flag; + const char *option_name; + const char *description; +}; + +static struct extension_category_info categories_info[] = { + {HOEDOWN_EXT_BLOCK, "block", "Block extensions"}, + {HOEDOWN_EXT_SPAN, "span", "Span extensions"}, + {HOEDOWN_EXT_FLAGS, "flags", "Other flags"}, + {HOEDOWN_EXT_NEGATIVE, "negative", "Negative flags"}, +}; + +static struct extension_info extensions_info[] = { + {HOEDOWN_EXT_TABLES, "tables", "Parse PHP-Markdown style tables."}, + {HOEDOWN_EXT_FENCED_CODE, "fenced-code", "Parse fenced code blocks."}, + {HOEDOWN_EXT_FOOTNOTES, "footnotes", "Parse footnotes."}, + + {HOEDOWN_EXT_AUTOLINK, "autolink", "Automatically turn URLs into links."}, + {HOEDOWN_EXT_STRIKETHROUGH, "strikethrough", "Parse ~~stikethrough~~ spans."}, + {HOEDOWN_EXT_UNDERLINE, "underline", "Parse _underline_ instead of emphasis."}, + {HOEDOWN_EXT_HIGHLIGHT, "highlight", "Parse ==highlight== spans."}, + {HOEDOWN_EXT_QUOTE, "quote", "Render \"quotes\" as quotes."}, + {HOEDOWN_EXT_SUPERSCRIPT, "superscript", "Parse super^script."}, + + {HOEDOWN_EXT_LAX_SPACING, "lax-spacing", "Allow HTML blocks on the same line as text."}, + {HOEDOWN_EXT_NO_INTRA_EMPHASIS, "disable-intra-emphasis", "Disable emphasis_between_words."}, + {HOEDOWN_EXT_SPACE_HEADERS, "space-headers", "Require a space after '#' in headers."}, + + {HOEDOWN_EXT_DISABLE_INDENTED_CODE, "disable-indented-code", "Don't parse indented code blocks."}, +}; + +static struct html_flag_info html_flags_info[] = { + {HOEDOWN_HTML_SKIP_HTML, "skip-html", "Strip all HTML tags."}, + {HOEDOWN_HTML_SKIP_STYLE, "skip-style", "Strip