From 2ff7c1f41b52921c3abea46ded8714b4fd9698b4 Mon Sep 17 00:00:00 2001 From: Nathan Phillip Brink Date: Mon, 13 Jul 2015 00:32:32 +0000 Subject: [PATCH] Convert compiletime ID Anchor setting to runtime flag for issue #124. Now specify flag `-fidanchor` or `MKD_IDANCHOR` instead of `./configure.sh --with-id-anchor`. In `markdown -VV` displays as `IDANCHOR` or `!IDANCHOR` rather than `ID-ANCHOR`. --- configure.sh | 4 +--- flags.c | 1 + generate.c | 38 +++++++++++++++++++------------------- markdown.1 | 2 ++ markdown.3 | 2 ++ markdown.h | 1 + mkdio.h.in | 1 + pgm_options.c | 1 + tests/toc.t | 49 ++++++++++++++++++++++++------------------------- version.c.in | 3 --- 10 files changed, 52 insertions(+), 50 deletions(-) diff --git a/configure.sh b/configure.sh index 17e98ae2..93c96a9c 100755 --- a/configure.sh +++ b/configure.sh @@ -9,7 +9,6 @@ # ac_help='--enable-amalloc Enable memory allocation debugging --with-tabstops=N Set tabstops to N characters (default is 4) ---with-id-anchor Use id= anchors for table-of-contents links --with-github-tags Allow `_` and `-` in <> tags --with-urlencoded-anchor Use url-encoded chars to multibyte chars in toc links --enable-all-features Turn on all stable optional features @@ -46,14 +45,13 @@ TARGET=markdown AC_INIT $TARGET -for banned_with in dl fenced-code; do +for banned_with in dl fenced-code id-anchor; do banned_with_variable_ref=\$WITH_`echo "$banned_with" | $AC_UPPERCASE | tr - _` if [ "`eval echo "$banned_with_variable_ref"`" ]; then AC_FAIL "Invalid option: --with-$banned_with. Please use a runtime flag to configure this feature." fi done -test "$WITH_ID_ANCHOR" && AC_DEFINE 'WITH_ID_ANCHOR' 1 test "$WITH_GITHUB_TAGS" && AC_DEFINE 'WITH_GITHUB_TAGS' 1 test "$WITH_URLENCODED_ANCHOR" && AC_DEFINE 'WITH_URLENCODED_ANCHOR' 1 test "$DEBIAN_GLITCH" && AC_DEFINE 'DEBIAN_GLITCH' 1 diff --git a/flags.c b/flags.c index cb7221aa..53717d54 100644 --- a/flags.c +++ b/flags.c @@ -33,6 +33,7 @@ static struct flagnames flagnames[] = { { MKD_NODLDISCOUNT, "!DLDISCOUNT" }, { MKD_DLEXTRA, "DLEXTRA" }, { MKD_FENCEDCODE, "FENCEDCODE" }, + { MKD_IDANCHOR, "IDANCHOR" }, }; #define NR(x) (sizeof x/sizeof x[0]) diff --git a/generate.c b/generate.c index 6573fc49..a91949ea 100644 --- a/generate.c +++ b/generate.c @@ -1426,26 +1426,26 @@ text(MMIOT *f) static void printheader(Paragraph *pp, MMIOT *f) { -#if WITH_ID_ANCHOR - Qprintf(f, "hnumber); - if ( f->flags & MKD_TOC ) { - Qstring(" id=\"", f); - mkd_string_to_anchor(T(pp->text->text), - S(pp->text->text), - (mkd_sta_function_t)Qchar, f, 1); - Qchar('"', f); - } - Qchar('>', f); -#else - if ( f->flags & MKD_TOC ) { - Qstring("text->text), - S(pp->text->text), - (mkd_sta_function_t)Qchar, f, 1); - Qstring("\">\n", f); + if ( f->flags & MKD_IDANCHOR ) { + Qprintf(f, "hnumber); + if ( f->flags & MKD_TOC ) { + Qstring(" id=\"", f); + mkd_string_to_anchor(T(pp->text->text), + S(pp->text->text), + (mkd_sta_function_t)Qchar, f, 1); + Qchar('"', f); + } + Qchar('>', f); + } else { + if ( f->flags & MKD_TOC ) { + Qstring("text->text), + S(pp->text->text), + (mkd_sta_function_t)Qchar, f, 1); + Qstring("\">\n", f); + } + Qprintf(f, "", pp->hnumber); } - Qprintf(f, "", pp->hnumber); -#endif push(T(pp->text->text), S(pp->text->text), f); text(f); Qprintf(f, "", pp->hnumber); diff --git a/markdown.1 b/markdown.1 index bdbcc1af..b31ab096 100644 --- a/markdown.1 +++ b/markdown.1 @@ -121,6 +121,8 @@ Allow markdown extra-style footnotes. Extract