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