summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Mendez <jmendeth@gmail.com>2014-03-29 14:10:08 +0100
committerXavier Mendez <jmendeth@gmail.com>2014-03-29 14:10:08 +0100
commitcc768b16e5d0dbb88fb6312ef0ca294fad355a7f (patch)
tree8f40aeb5605f8dc0018acfd20e997834ed227ce0
parentd7de54037618d47d523548bd2824fab5b1e742aa (diff)
downloadrust-hoedown-cc768b16e5d0dbb88fb6312ef0ca294fad355a7f.tar.gz
Remove useless HTML_TOC flag
It's redundant. A zero `nesting_level` already means "disable TOC" and a nonzero `nesting_level` enables it. Having a TOC flag only complicates the code unnecessarily.
-rw-r--r--bin/hoedown.c3
-rw-r--r--src/html.c13
-rw-r--r--src/html.h7
3 files changed, 7 insertions, 16 deletions
diff --git a/bin/hoedown.c b/bin/hoedown.c
index 960bb3e..812b1f6 100644
--- a/bin/hoedown.c
+++ b/bin/hoedown.c
@@ -79,7 +79,6 @@ static struct html_flag_info html_flags_info[] = {
{HOEDOWN_HTML_SKIP_LINKS, "skip-links", "Don't render links."},
{HOEDOWN_HTML_EXPAND_TABS, "expand-tabs", "Expand tabs to spaces."},
{HOEDOWN_HTML_SAFELINK, "safelink", "Only allow links to safe protocols."},
- {HOEDOWN_HTML_TOC, "toc", "Produce links to the Table of Contents."},
{HOEDOWN_HTML_HARD_WRAP, "hard-wrap", "Render each linebreak as <br>."},
{HOEDOWN_HTML_USE_XHTML, "xhtml", "Render XHTML."},
{HOEDOWN_HTML_ESCAPE, "escape", "Escape all HTML."},
@@ -107,7 +106,7 @@ print_help(const char *basename) {
/* main options */
printf("Main options:\n");
print_option('n', "max-nesting=N", "Maximum level of block nesting parsed. Default is " str(DEF_MAX_NESTING) ".");
- print_option('t', "toc-level=N", "Maximum level for headers included in the TOC. Implies '--toc'.");
+ print_option('t', "toc-level=N", "Maximum level for headers included in the TOC. Zero disables TOC (the default).");
print_option( 0, "html", "Render (X)HTML. The default.");
print_option( 0, "html-toc", "Render the Table of Contents in (X)HTML.");
print_option( 0, "null", "Use a special \"null\" renderer that has no callbacks.");
diff --git a/src/html.c b/src/html.c
index 7d89c46..c4fb25e 100644
--- a/src/html.c
+++ b/src/html.c
@@ -224,7 +224,7 @@ rndr_header(hoedown_buffer *ob, const hoedown_buffer *text, int level, void *opa
if (ob->size)
hoedown_buffer_putc(ob, '\n');
- if ((state->flags & HOEDOWN_HTML_TOC) && (level <= state->toc_data.nesting_level))
+ if (level <= state->toc_data.nesting_level)
hoedown_buffer_printf(ob, "<h%d id=\"toc_%d\">", level, state->toc_data.header_count++);
else
hoedown_buffer_printf(ob, "<h%d>", level);
@@ -650,10 +650,7 @@ hoedown_html_toc_renderer_new(int nesting_level)
memset(state, 0x0, sizeof(hoedown_html_renderer_state));
- if (nesting_level > 0) {
- state->flags |= HOEDOWN_HTML_TOC;
- state->toc_data.nesting_level = nesting_level;
- }
+ state->toc_data.nesting_level = nesting_level;
/* Prepare the renderer */
renderer = malloc(sizeof(hoedown_renderer));
@@ -722,11 +719,7 @@ hoedown_html_renderer_new(unsigned int render_flags, int nesting_level)
memset(state, 0x0, sizeof(hoedown_html_renderer_state));
state->flags = render_flags;
-
- if (nesting_level > 0) {
- state->flags |= HOEDOWN_HTML_TOC;
- state->toc_data.nesting_level = nesting_level;
- }
+ state->toc_data.nesting_level = nesting_level;
/* Prepare the renderer */
renderer = malloc(sizeof(hoedown_renderer));
diff --git a/src/html.h b/src/html.h
index 8002bab..e34ef9d 100644
--- a/src/html.h
+++ b/src/html.h
@@ -18,10 +18,9 @@ typedef enum {
HOEDOWN_HTML_SKIP_LINKS = (1 << 3),
HOEDOWN_HTML_EXPAND_TABS = (1 << 4),
HOEDOWN_HTML_SAFELINK = (1 << 5),
- HOEDOWN_HTML_TOC = (1 << 6),
- HOEDOWN_HTML_HARD_WRAP = (1 << 7),
- HOEDOWN_HTML_USE_XHTML = (1 << 8),
- HOEDOWN_HTML_ESCAPE = (1 << 9)
+ HOEDOWN_HTML_HARD_WRAP = (1 << 6),
+ HOEDOWN_HTML_USE_XHTML = (1 << 7),
+ HOEDOWN_HTML_ESCAPE = (1 << 8)
} hoedown_html_render_mode;
typedef enum {