strip out MKD_STRICT as a single flag (convert it into a composite flag that turns off a whole bunch of extensions); use that flagbit to disable github checkbox items, strip out MKD_DLIST as a single flag (convert it into a mask of MKD_DLDISCOUNT|MKD_DLEXTRA, and rework pgm_options so that 'strict' and 'relaxed' apply only to emphasis and 'standard' is the flag that sets & clears flags to make it closer to the standard. Version 3 because I'm fucking with the published interface

This commit is contained in:
david parsons
2019-04-14 20:56:55 -07:00
parent 2be654fdeb
commit b52ec440d4
16 changed files with 111 additions and 103 deletions
+1 -1
View File
@@ -1 +1 @@
2.2.6
3
+10 -9
View File
@@ -45,12 +45,11 @@ locals() {
--CXX-BINDING)
echo CXX_BINDING=T
;;
--GITHUB-CHECKBOX)
echo GITHUB_CHECKBOX=T
--GITHUB-CHECKBOX|--GITHUB-CHECKBOX=ENTITY)
echo GITHUB_CHECKBOX_STYLE=entity
;;
--GITHUB-CHECKBOX=INPUT)
echo GITHUB_CHECKBOX=T
echo GITHUB_CHECKBOX_AS_INPUT=T
echo GITHUB_CHECKBOX_STYLE=input
;;
esac
}
@@ -79,8 +78,9 @@ done
# theme wants the old behavior of --with-(foo)
#
case "`echo "$WITH_DL" | $AC_UPPERCASE`" in
EXTRA) THEME_CF="MKD_DLEXTRA|MKD_NODLDISCOUNT";;
BOTH) THEME_CF="MKD_DLEXTRA";;
DISCOUNT) THEME_CF="MKD_DLDISCOUNT";;
EXTRA) THEME_CF="MKD_DLEXTRA";;
BOTH) THEME_CF="MKD_DLIST";;
esac
test "$WITH_FENCED_CODE" && THEME_CF="${THEME_CF:+$THEME_CF|}MKD_FENCEDCODE"
@@ -232,9 +232,10 @@ else
AC_SUB 'H1TITLE' ''
fi
if [ "$GITHUB_CHECKBOX" ]; then
AC_DEFINE 'GITHUB_CHECKBOX' '1'
test "$GITHUB_CHECKBOX_AS_INPUT" && AC_DEFINE 'CHECKBOX_AS_INPUT' '1'
if [ "$GITHUB_CHECKBOX_STYLE" = "entity" ]; then
AC_DEFINE 'CHECKBOX_AS_INPUT' '0'
else
AC_DEFINE 'CHECKBOX_AS_INPUT' '1'
fi
-2
View File
@@ -115,10 +115,8 @@ dumptree(Paragraph *pp, Stack *sp, FILE *f)
if ( pp->ident )
d += fprintf(f, " %s", pp->ident);
#ifdef GITHUB_CHECKBOX
if ( pp->flags )
d += fprintf(f, " %x", pp->flags);
#endif
if ( pp->align > 1 )
d += fprintf(f, ", <%s>", Begin[pp->align]);
+2 -3
View File
@@ -11,7 +11,6 @@ static struct flagnames flagnames[] = {
{ MKD_NOIMAGE, "!IMAGE" },
{ MKD_NOPANTS, "!PANTS" },
{ MKD_NOHTML, "!HTML" },
{ MKD_STRICT, "STRICT" },
{ MKD_TAGTEXT, "TAGTEXT" },
{ MKD_NO_EXT, "!EXT" },
{ MKD_CDATA, "CDATA" },
@@ -27,14 +26,14 @@ static struct flagnames flagnames[] = {
{ MKD_TABSTOP, "TABSTOP" },
{ MKD_NODIVQUOTE, "!DIVQUOTE" },
{ MKD_NOALPHALIST, "!ALPHALIST" },
{ MKD_NODLIST, "!DLIST" },
{ MKD_EXTRA_FOOTNOTE, "FOOTNOTE" },
{ MKD_NOSTYLE, "!STYLE" },
{ MKD_NODLDISCOUNT, "!DLDISCOUNT" },
{ MKD_DLDISCOUNT, "DLDISCOUNT" },
{ MKD_DLEXTRA, "DLEXTRA" },
{ MKD_FENCEDCODE, "FENCEDCODE" },
{ MKD_IDANCHOR, "IDANCHOR" },
{ MKD_GITHUBTAGS, "GITHUBTAGS" },
{ MKD_NORMAL_LISTITEM, "NORMAL_LISTITEM" },
{ MKD_URLENCODEDANCHOR, "URLENCODEDANCHOR" },
{ MKD_LATEX, "LATEX" },
{ MKD_EXPLICITLIST, "EXPLICITLIST" },
+2 -11
View File
@@ -1352,7 +1352,6 @@ text(MMIOT *f)
break;
/* A^B -> A<sup>B</sup> */
case '^': if ( is_flag_set(f->flags, MKD_NOSUPERSCRIPT)
|| is_flag_set(f->flags, MKD_STRICT)
|| is_flag_set(f->flags, MKD_TAGTEXT)
|| (f->last == 0)
|| ((ispunct(f->last) || isspace(f->last))
@@ -1390,7 +1389,7 @@ text(MMIOT *f)
break;
case '_':
/* Underscores don't count if they're in the middle of a word */
if ( !(is_flag_set(f->flags, MKD_NORELAXED) || is_flag_set(f->flags, MKD_STRICT))
if ( !is_flag_set(f->flags, MKD_NORELAXED)
&& isthisalnum(f,-1) && isthisalnum(f,1) ) {
Qchar(c, f);
break;
@@ -1413,7 +1412,6 @@ text(MMIOT *f)
break;
case '~': if ( is_flag_set(f->flags, MKD_NOSTRIKETHROUGH)
|| is_flag_set(f->flags, MKD_STRICT)
|| is_flag_set(f->flags, MKD_TAGTEXT)
|| ! tickhandler(f,c,2,0, delspan) )
Qchar(c, f);
@@ -1437,8 +1435,7 @@ text(MMIOT *f)
}
break;
case '^': if ( is_flag_set(f->flags, MKD_STRICT)
|| is_flag_set(f->flags, MKD_NOSUPERSCRIPT) ) {
case '^': if ( is_flag_set(f->flags, MKD_NOSUPERSCRIPT) ) {
Qchar('\\', f);
shift(f,-1);
break;
@@ -1779,7 +1776,6 @@ htmlify_paragraphs(Paragraph *p, MMIOT *f)
}
#ifdef GITHUB_CHECKBOX
static void
li_htmlify(Paragraph *p, char *arguments, mkd_flag_t flags, MMIOT *f)
{
@@ -1808,7 +1804,6 @@ li_htmlify(Paragraph *p, char *arguments, mkd_flag_t flags, MMIOT *f)
Qprintf(f, "</li>");
___mkd_emblock(f);
}
#endif
static void
@@ -1860,11 +1855,7 @@ listdisplay(int typ, Paragraph *p, MMIOT* f)
Qprintf(f, ">\n");
for ( ; p ; p = p->next ) {
#ifdef GITHUB_CHECKBOX
li_htmlify(p->down, p->ident, p->flags, f);
#else
htmlify(p->down, "li", p->ident, f);
#endif
Qchar('\n', f);
}
+1 -2
View File
@@ -59,8 +59,7 @@ gfm_populate(getc_func getc, void* ctx, int flags)
DELETE(line);
if ( (pandoc == 3) && !(is_flag_set(flags, MKD_NOHEADER)
|| is_flag_set(flags, MKD_STRICT)) ) {
if ( (pandoc == 3) && !is_flag_set(flags, MKD_NOHEADER) ) {
/* the first three lines started with %, so we have a header.
* clip the first three lines out of content and hang them
* off header.
+4 -2
View File
@@ -263,8 +263,10 @@ main(int argc, char **argv)
if ( version ) {
printf("%s: discount %s%s", pgm, markdown_version,
with_html5 ? " +html5":"");
if ( version > 1 )
if ( version == 2 )
mkd_flags_are(stdout, flags, 0);
if ( version >= 3 )
printf(" MARKDOWN_FLAGS=0x%08x", flags);
putchar('\n');
exit(0);
}
@@ -308,7 +310,7 @@ main(int argc, char **argv)
if ( squash )
mkd_e_anchor(doc, (mkd_callback_t) anchor_format);
if ( use_e_codefmt )
mkd_e_code_format(doc, external_codefmt);
mkd_e_code_format(doc, (mkd_callback_t)external_codefmt);
if ( use_e_codefmt || squash )
mkd_e_free(doc, free_it);
+6 -11
View File
@@ -445,7 +445,7 @@ end_of_block(Line *t, mkd_flag_t flags)
static Line*
is_discount_dt(Line *t, int *clip, mkd_flag_t flags)
{
if ( !is_flag_set(flags, MKD_NODLDISCOUNT)
if ( is_flag_set(flags, MKD_DLDISCOUNT)
&& t
&& t->next
&& (S(t->text) > 2)
@@ -518,8 +518,7 @@ islist(Line *t, int *clip, mkd_flag_t flags, int *list_type)
if ( end_of_block(t, flags) )
return 0;
if ( !(is_flag_set(flags, MKD_NODLIST) || is_flag_set(flags, MKD_STRICT))
&& isdefinition(t,clip,list_type,flags) )
if ( is_flag_set(flags, MKD_DLIST) && isdefinition(t,clip,list_type,flags) )
return DL;
if ( strchr("*-+", T(t->text)[t->dle]) && isspace(T(t->text)[t->dle+1]) ) {
@@ -532,7 +531,7 @@ islist(Line *t, int *clip, mkd_flag_t flags, int *list_type)
if ( (j = nextblank(t,t->dle)) > t->dle ) {
if ( T(t->text)[j-1] == '.' ) {
if ( !(is_flag_set(flags, MKD_NOALPHALIST) || is_flag_set(flags, MKD_STRICT))
if ( !is_flag_set(flags, MKD_NOALPHALIST)
&& (j == t->dle + 2)
&& isalpha(T(t->text)[t->dle]) ) {
j = nextnonblank(t,j);
@@ -755,7 +754,7 @@ isdivmarker(Line *p, int start, mkd_flag_t flags)
char *s;
int last, i;
if ( is_flag_set(flags, MKD_NODIVQUOTE) || is_flag_set(flags, MKD_STRICT) )
if ( is_flag_set(flags, MKD_NODIVQUOTE) )
return 0;
start = nextnonblank(p, start);
@@ -854,20 +853,17 @@ listitem(Paragraph *p, int indent, mkd_flag_t flags, linefn check)
Line *t, *q;
int clip = indent;
int z;
#ifdef GITHUB_CHECKBOX
int firstpara = 1;
int ischeck;
#define CHECK_NOT 0
#define CHECK_NO 1
#define CHECK_YES 2
#endif
for ( t = p->text; t ; t = q) {
UNCHECK(t);
__mkd_trim_line(t, clip);
#ifdef GITHUB_CHECKBOX
if ( firstpara ) {
if ( firstpara && !is_flag_set(flags, MKD_NORMAL_LISTITEM) ) {
ischeck = CHECK_NOT;
if ( strncmp(T(t->text)+t->dle, "[ ]", 3) == 0 )
ischeck = CHECK_NO;
@@ -882,7 +878,6 @@ listitem(Paragraph *p, int indent, mkd_flag_t flags, linefn check)
}
firstpara = 0;
}
#endif
/* even though we had to trim a long leader off this item,
* the indent for trailing paragraphs is still 4...
@@ -1268,7 +1263,7 @@ actually_a_table(MMIOT *f, Line *pp)
int c;
/* tables need to be turned on */
if ( is_flag_set(f->flags, MKD_STRICT) || is_flag_set(f->flags, MKD_NOTABLES) )
if ( is_flag_set(f->flags, MKD_NOTABLES) )
return 0;
/* tables need three lines */
+9 -5
View File
@@ -55,11 +55,9 @@ typedef struct paragraph {
HDR, HR, TABLE, SOURCE } typ;
enum { IMPLICIT=0, PARA, CENTER} align;
int hnumber; /* <Hn> for typ == HDR */
#if GITHUB_CHECKBOX
int flags;
#define GITHUB_CHECK 0x01
#define IS_CHECKED 0x02
#endif
} Paragraph;
enum { ETX, SETEXT }; /* header types */
@@ -135,7 +133,7 @@ typedef struct mmiot {
#define MKD_NOIMAGE 0x00000002
#define MKD_NOPANTS 0x00000004
#define MKD_NOHTML 0x00000008
#define MKD_STRICT 0x00000010
#define MKD_NORMAL_LISTITEM 0x00000010
#define MKD_TAGTEXT 0x00000020
#define MKD_NO_EXT 0x00000040
#define MKD_CDATA 0x00000080
@@ -151,10 +149,9 @@ typedef struct mmiot {
#define MKD_TABSTOP 0x00020000
#define MKD_NODIVQUOTE 0x00040000
#define MKD_NOALPHALIST 0x00080000
#define MKD_NODLIST 0x00100000
#define MKD_EXTRA_FOOTNOTE 0x00200000
#define MKD_NOSTYLE 0x00400000
#define MKD_NODLDISCOUNT 0x00800000
#define MKD_DLDISCOUNT 0x00800000
#define MKD_DLEXTRA 0x01000000
#define MKD_FENCEDCODE 0x02000000
#define MKD_IDANCHOR 0x04000000
@@ -166,6 +163,13 @@ typedef struct mmiot {
#define USER_FLAGS 0xFFFFFFFF
#define INPUT_MASK (MKD_NOHEADER|MKD_TABSTOP)
/* composite flags */
#define MKD_DLIST MKD_DLDISCOUNT|MKD_DLEXTRA
#define MKD_STRICT MKD_NOSUPERSCRIPT|MKD_NORELAXED|MKD_NOSTRIKETHROUGH| \
MKD_NOHEADER|MKD_NOALPHALIST|MKD_NODIVQUOTE| \
MKD_NOTABLES|MKD_NO_EXT|MKD_NOSTYLE|MKD_NORMAL_LISTITEM| \
MKD_TABSTOP
Callback_data *cb;
} MMIOT;
+1 -1
View File
@@ -128,7 +128,7 @@ populate(getc_func getc, void* ctx, mkd_flag_t flags)
DELETE(line);
if ( (pandoc == 3) && !(is_flag_set(flags, MKD_NOHEADER) || is_flag_set(flags, MKD_STRICT)) ) {
if ( (pandoc == 3) && !is_flag_set(flags, MKD_NOHEADER) ) {
/* the first three lines started with %, so we have a header.
* clip the first three lines out of content and hang them
* off header.
+8 -3
View File
@@ -87,7 +87,7 @@ void mkd_ref_prefix(MMIOT*, char*);
#define MKD_NOIMAGE 0x00000002 /* don't do image processing, block <img> */
#define MKD_NOPANTS 0x00000004 /* don't run smartypants() */
#define MKD_NOHTML 0x00000008 /* don't allow raw html through AT ALL */
#define MKD_STRICT 0x00000010 /* disable SUPERSCRIPT, RELAXED_EMPHASIS */
#define MKD_NORMAL_LISTITEM 0x00000010 /* disable github-style checkbox lists */
#define MKD_TAGTEXT 0x00000020 /* process text inside an html tag; no
* <em>, no <bold>, no html or [] expansion */
#define MKD_NO_EXT 0x00000040 /* don't allow pseudo-protocols */
@@ -105,10 +105,9 @@ void mkd_ref_prefix(MMIOT*, char*);
#define MKD_TABSTOP 0x00020000 /* expand tabs to 4 spaces */
#define MKD_NODIVQUOTE 0x00040000 /* forbid >%class% blocks */
#define MKD_NOALPHALIST 0x00080000 /* forbid alphabetic lists */
#define MKD_NODLIST 0x00100000 /* forbid definition lists */
#define MKD_EXTRA_FOOTNOTE 0x00200000 /* enable markdown extra-style footnotes */
#define MKD_NOSTYLE 0x00400000 /* don't extract <style> blocks */
#define MKD_NODLDISCOUNT 0x00800000 /* disable discount-style definition lists */
#define MKD_DLDISCOUNT 0x00800000 /* enable discount-style definition lists */
#define MKD_DLEXTRA 0x01000000 /* enable extra-style definition lists */
#define MKD_FENCEDCODE 0x02000000 /* enabled fenced code blocks */
#define MKD_IDANCHOR 0x04000000 /* use id= anchors for TOC links */
@@ -118,6 +117,12 @@ void mkd_ref_prefix(MMIOT*, char*);
#define MKD_EXPLICITLIST 0x80000000 /* don't combine numbered/bulletted lists */
#define MKD_EMBED MKD_NOLINKS|MKD_NOIMAGE|MKD_TAGTEXT
#define MKD_DLIST MKD_DLDISCOUNT|MKD_DLEXTRA
#define MKD_STRICT MKD_NOSUPERSCRIPT|MKD_NORELAXED|MKD_NOSTRIKETHROUGH| \
MKD_NOHEADER|MKD_NOALPHALIST|MKD_NODIVQUOTE| \
MKD_NOTABLES|MKD_NO_EXT|MKD_NOSTYLE|MKD_NORMAL_LISTITEM| \
MKD_TABSTOP
/* special flags for mkd_in() and mkd_string()
*/
+52 -40
View File
@@ -24,45 +24,51 @@ static struct _opt {
char *name;
char *desc;
int off;
int skip; /* this opt is a synonym */
int skip; /* this opt is a synonym; don't display in -F? */
int composite; /* composite flag; don't display in -F? */
int sayenable;
mkd_flag_t flag;
mkd_flag_t flag; /* flags to set/clear */
mkd_flag_t unflag; /* flags to clear/set */
} opts[] = {
{ "tabstop", "default (4-space) tabstops", 0, 0, 1, MKD_TABSTOP },
{ "image", "images", 1, 0, 1, MKD_NOIMAGE },
{ "links", "links", 1, 0, 1, MKD_NOLINKS },
{ "relax", "emphasis inside words", 1, 1, 1, MKD_STRICT },
{ "strict", "emphasis inside words", 0, 0, 1, MKD_STRICT },
{ "tables", "tables", 1, 0, 1, MKD_NOTABLES },
{ "header", "pandoc-style headers", 1, 0, 1, MKD_NOHEADER },
{ "html", "raw html", 1, 0, 1, MKD_NOHTML },
{ "ext", "extended protocols", 1, 0, 1, MKD_NO_EXT },
{ "cdata", "generate cdata", 0, 0, 0, MKD_CDATA },
{ "smarty", "smartypants", 1, 0, 1, MKD_NOPANTS },
{ "pants", "smartypants", 1, 1, 1, MKD_NOPANTS },
{ "toc", "tables of contents", 0, 0, 1, MKD_TOC },
{ "autolink", "autolinking", 0, 0, 1, MKD_AUTOLINK },
{ "safelink", "safe links", 0, 0, 1, MKD_SAFELINK },
{ "strikethrough", "strikethrough", 1, 0, 1, MKD_NOSTRIKETHROUGH },
{ "del", "strikethrough", 1, 1, 1, MKD_NOSTRIKETHROUGH },
{ "superscript", "superscript", 1, 0, 1, MKD_NOSUPERSCRIPT },
{ "emphasis", "emphasis inside words", 0, 0, 1, MKD_NORELAXED },
{ "divquote", ">%class% blockquotes", 1, 0, 1, MKD_NODIVQUOTE },
{ "alphalist", "alpha lists", 1, 0, 1, MKD_NOALPHALIST },
{ "definitionlist","definition lists", 1, 0, 1, MKD_NODLIST },
{ "1.0", "markdown 1.0 compatibility", 0, 0, 1, MKD_1_COMPAT },
{ "footnotes", "markdown extra footnotes", 0, 0, 1, MKD_EXTRA_FOOTNOTE },
{ "footnote", "markdown extra footnotes", 0, 1, 1, MKD_EXTRA_FOOTNOTE },
{ "style", "extract style blocks", 1, 0, 1, MKD_NOSTYLE },
{ "dldiscount", "discount-style definition lists", 1, 0, 1, MKD_NODLDISCOUNT },
{ "dlextra", "extra-style definition lists", 0, 0, 1, MKD_DLEXTRA },
{ "fencedcode", "fenced code blocks", 0, 0, 1, MKD_FENCEDCODE },
{ "idanchor", "id= anchors in TOC", 0, 0, 1, MKD_IDANCHOR },
{ "githubtags", "permit - and _ in element names", 0, 0, 0, MKD_GITHUBTAGS },
{ "urlencodedanchor", "html5-style anchors", 0, 0, 0, MKD_URLENCODEDANCHOR },
{ "html5anchor", "html5-style anchors", 0, 1, 0, MKD_URLENCODEDANCHOR },
{ "latex", "handle LaTeX escapes", 0, 0, 1, MKD_LATEX },
{ "explicitlist", "do not merge adjacent numeric/bullet lists", 0, 0, 1, MKD_EXPLICITLIST },
{ "tabstop", "default (4-space) tabstops", 0, 0, 0, 1, MKD_TABSTOP },
{ "image", "images", 1, 0, 0, 1, MKD_NOIMAGE },
{ "links", "links", 1, 0, 0, 1, MKD_NOLINKS },
{ "strict", "emphasis inside words", 0, 0, 0, 1, MKD_NORELAXED },
{ "relax", "emphasis inside words", 1, 1, 0, 1, MKD_NORELAXED },
{ "tables", "tables", 1, 0, 0, 1, MKD_NOTABLES },
{ "header", "pandoc-style headers", 1, 0, 0, 1, MKD_NOHEADER },
{ "html", "allow raw html", 1, 0, 0, 0, MKD_NOHTML },
{ "ext", "extended protocols", 1, 0, 0, 1, MKD_NO_EXT },
{ "cdata", "generate cdata", 0, 0, 0, 0, MKD_CDATA },
{ "smarty", "smartypants", 1, 0, 0, 1, MKD_NOPANTS },
{ "pants", "smartypants", 1, 1, 0, 1, MKD_NOPANTS },
{ "toc", "tables of contents", 0, 0, 0, 1, MKD_TOC },
{ "autolink", "autolinking", 0, 0, 0, 1, MKD_AUTOLINK },
{ "safelink", "safe links", 0, 0, 0, 1, MKD_SAFELINK },
{ "strikethrough", "strikethrough", 1, 0, 0, 1, MKD_NOSTRIKETHROUGH },
{ "del", "strikethrough", 1, 1, 0, 1, MKD_NOSTRIKETHROUGH },
{ "superscript", "superscript", 1, 0, 0, 1, MKD_NOSUPERSCRIPT },
{ "divquote", ">%class% blockquotes", 1, 0, 0, 1, MKD_NODIVQUOTE },
{ "alphalist", "alpha lists", 1, 0, 0, 1, MKD_NOALPHALIST },
{ "definitionlist","both discount & markdown extra definition lists", 0, 0, 1, 1, MKD_DLIST },
{ "dlist", "both discount & markdown extra definition lists", 0, 1, 1, 1, MKD_DLIST },
{ "1.0", "markdown 1.0 compatibility", 0, 0, 0, 1, MKD_1_COMPAT },
{ "footnotes", "markdown extra footnotes", 0, 0, 0, 1, MKD_EXTRA_FOOTNOTE },
{ "footnote", "markdown extra footnotes", 0, 1, 0, 1, MKD_EXTRA_FOOTNOTE },
{ "style", "extract style blocks", 1, 0, 0, 1, MKD_NOSTYLE },
{ "dldiscount", "discount-style definition lists", 0, 0, 0, 1, MKD_DLDISCOUNT },
{ "dlextra", "markdown extra-style definition lists", 0, 0, 0, 1, MKD_DLEXTRA },
{ "fencedcode", "fenced code blocks", 0, 0, 0, 1, MKD_FENCEDCODE },
{ "idanchor", "id= anchors in TOC", 0, 0, 0, 1, MKD_IDANCHOR },
{ "githubtags", "- and _ in element names", 0, 0, 0, 1, MKD_GITHUBTAGS },
{ "urlencodedanchor", "html5-style anchors", 0, 0, 0, 1, MKD_URLENCODEDANCHOR },
{ "html5anchor", "html5-style anchors", 0, 1, 0, 1, MKD_URLENCODEDANCHOR },
{ "latex", "LaTeX escapes", 0, 0, 0, 1, MKD_LATEX },
{ "explicitlist", "merge adjacent numeric/bullet lists", 0, 0, 0, 0, MKD_EXPLICITLIST },
{ "github-listitem","github-style check items", 1, 0, 0, 1, MKD_NORMAL_LISTITEM } ,
{ "regular-listitem","github-style check items", 0, 1, 0, 1, MKD_NORMAL_LISTITEM } ,
{ "standard", "conform to the markdown standard", 0, 0, 1, 0, MKD_STRICT,
MKD_FENCEDCODE|MKD_LATEX|MKD_TABSTOP|MKD_EXTRA_FOOTNOTE|MKD_AUTOLINK|MKD_SAFELINK|MKD_TOC|MKD_DLIST },
} ;
#define NR(x) (sizeof x / sizeof x[0])
@@ -99,7 +105,7 @@ show_flags(int byname, int verbose)
qsort(opts, NR(opts), sizeof(opts[0]), (stfu)sort_by_flag);
for (i=0; i < NR(opts); i++)
if ( !opts[i].skip ) {
if ( !(opts[i].skip || opts[i].composite) ) {
fprintf(stderr, "%08lx : ", (long)opts[i].flag);
if ( opts[i].sayenable )
fprintf(stderr, opts[i].off ? "disable " : "enable ");
@@ -134,10 +140,16 @@ set_flag(mkd_flag_t *flags, char *optionstring)
if ( opts[i].off )
enable = !enable;
if ( enable )
if ( enable ) {
*flags |= opts[i].flag;
else
if ( opts[i].unflag )
*flags &= ~opts[i].unflag;
}
else {
*flags &= ~opts[i].flag;
if ( opts[i].unflag )
*flags |= opts[i].unflag;
}
}
else
return arg;
+7 -7
View File
@@ -19,9 +19,9 @@ RSLT='<dl>
</dl>'
# discount style
try -fdefinitionlist '=tag= generates definition lists' "$SRC" "$RSLT"
try -fdldiscount '=tag= generates definition lists' "$SRC" "$RSLT"
try 'one item with two =tags=' \
try -fdldiscount 'one item with two =tags=' \
'=this=
=is=
A test, eh?' \
@@ -32,7 +32,7 @@ try 'one item with two =tags=' \
</dl>'
# extra style
try -fnodefinitionlist,dlextra '=tag= does nothing' "$SRC" \
try -fdlextra '=tag= does nothing' "$SRC" \
'<p>=this=
is an ugly
=test=
@@ -90,12 +90,12 @@ RSLT='<p>foo
<p>=this=
is ugly</p>'
try -fnodldiscount '... with definitionlists enabled but all styles disabled' \
"$SRC" \
"$RSLT"
try -fnodefinitionlist,dldiscount,dlextra '... with definitionlists disabled but all styles enabled' \
try -fdlist,nodldiscount,nodlextra '... with definitionlists enabled but all styles disabled' \
"$SRC" \
"$RSLT"
#try -fnodefinitionlist,dldiscount,dlextra '... with definitionlists disabled but all styles enabled' \
# "$SRC" \
# "$RSLT"
summary $0
exit $rc
+2 -2
View File
@@ -124,7 +124,7 @@ try 'blockquote inside a list' \
<blockquote><p>This is a quote insde a list item.</p></blockquote></li>
</ul>'
try 'dl followed by non-dl' \
try -fdlist 'dl followed by non-dl' \
'=a=
test
2. here' \
@@ -137,7 +137,7 @@ try 'dl followed by non-dl' \
<li>here</li>
</ol>'
try 'non-dl followed by dl' \
try -fdlist 'non-dl followed by dl' \
'1. hello
=sailor=
hi!' \
+2 -2
View File
@@ -5,8 +5,8 @@ title "superscript"
rc=0
MARKDOWN_FLAGS=0x0; export MARKDOWN_FLAGS
try -frelax 'A^B -> A<sup>B</sup> (-frelax)' 'A^B' '<p>A<sup>B</sup></p>'
try -fstrict 'A^B != A<sup>B</sup> (-fstrict)' 'A^B' '<p>A^B</p>'
try -fsuperscript 'A^B -> A<sup>B</sup> (-fsuperscript)' 'A^B' '<p>A<sup>B</sup></p>'
try -fstandard 'A^B != A<sup>B</sup> (-fstandard)' 'A^B' '<p>A^B</p>'
try -fnosuperscript 'A^B != A<sup>B</sup> (-fnosuperscript)' 'A^B' '<p>A^B</p>'
try -frelax 'A^B in link title' '[link](here "A^B")' '<p><a href="here" title="A^B">link</a></p>'
try 'A^(B+2)C^2' 'A^(B+2)C^2' '<p>A<sup>B+2</sup>C<sup>2</sup></p>'
+4 -2
View File
@@ -7,7 +7,9 @@ char markdown_version[] = BRANCH VERSION
#if USE_AMALLOC
" DEBUG"
#endif
#if GITHUB_CHECKBOX
" GITHUB_CHECKBOX"
#if CHECKBOX_AS_INPUT
" GHC=INPUT"
#else
" GHC=ENTITY"
#endif
;