[Reproducible-commits] [discount] 81/121: Imported Upstream version 2.1.5
Jérémy Bobbio
lunar at moszumanska.debian.org
Tue Sep 23 20:56:19 UTC 2014
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch pu/reproducible_builds
in repository discount.
commit a891dc031ba09f110f64e1aca92dba905a5abfdb
Author: Alessandro Ghedini <al3xbio at gmail.com>
Date: Wed Aug 8 21:01:30 2012 +0200
Imported Upstream version 2.1.5
---
Csio.c | 2 +-
Makefile.in | 13 +++---
VERSION | 2 +-
configure.inc | 128 +++++++++++++++++++++++++++++++----------------------
configure.sh | 19 ++++++--
cstring.h | 4 +-
flags.c | 1 +
generate.c | 101 ++++++++++++++++++++++++++----------------
github_flavoured.c | 100 +++++++++++++++++++++++++++++++++++++++++
main.c | 30 ++++++++++---
markdown.1 | 14 ++++--
markdown.c | 40 ++++++++++++-----
markdown.h | 37 ++++++++++++++--
mkd2html.c | 27 ++++++-----
mkdio.c | 42 ++++++++----------
mkdio.h.in | 6 +++
pgm_options.c | 7 ++-
tests/code.t | 15 +++++++
tests/style.t | 2 +
theme.1 | 2 +
theme.c | 22 +++++++--
21 files changed, 446 insertions(+), 168 deletions(-)
diff --git a/Csio.c b/Csio.c
index 4358b33..5706657 100644
--- a/Csio.c
+++ b/Csio.c
@@ -54,7 +54,7 @@ Csreparse(Cstring *iot, char *buf, int size, int flags)
{
MMIOT f;
___mkd_initmmiot(&f, 0);
- ___mkd_reparse(buf, size, 0, &f);
+ ___mkd_reparse(buf, size, 0, &f, 0);
___mkd_emblock(&f);
SUFFIX(*iot, T(f.out), S(f.out));
___mkd_freemmiot(&f, 0);
diff --git a/Makefile.in b/Makefile.in
index eeedf4c..9bb438a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,5 @@
-CC=@CC@ -I. -L.
+CC=@CC@ -I.
+LFLAGS=-L.
CFLAGS=@CFLAGS@
AR=@AR@
RANLIB=@RANLIB@
@@ -15,7 +16,7 @@ MKDLIB=libmarkdown
OBJS=mkdio.o markdown.o dumptree.o generate.o \
resource.o docheader.o version.o toc.o css.o \
xml.o Csio.o xmlpage.o basename.o emmatch.o \
- setup.o tags.o html5.o flags.o @AMALLOC@
+ github_flavoured.o setup.o tags.o html5.o flags.o @AMALLOC@
TESTFRAMEWORK=echo cols
MAN3PAGES=mkd-callbacks.3 mkd-functions.3 markdown.3 mkd-line.3
@@ -75,17 +76,17 @@ blocktags: mktags
# example programs
@THEME at theme: theme.o $(MKDLIB) mkdio.h
- at THEME@ $(CC) -o theme theme.o -lmarkdown @LIBS@
+ at THEME@ $(CC) $(LFLAGS) -o theme theme.o pgm_options.o -lmarkdown @LIBS@
mkd2html: mkd2html.o $(MKDLIB) mkdio.h
- $(CC) -o mkd2html mkd2html.o -lmarkdown @LIBS@
+ $(CC) $(LFLAGS) -o mkd2html mkd2html.o -lmarkdown @LIBS@
markdown: main.o pgm_options.o $(MKDLIB)
- $(CC) $(CFLAGS) -o markdown main.o pgm_options.o -lmarkdown @LIBS@
+ $(CC) $(LFLAGS) -o markdown main.o pgm_options.o -lmarkdown @LIBS@
makepage: makepage.c pgm_options.o $(MKDLIB) mkdio.h
- $(CC) $(CFLAGS) -o makepage makepage.c pgm_options.o -lmarkdown @LIBS@
+ $(CC) $(LFLAGS) -o makepage makepage.c pgm_options.o -lmarkdown @LIBS@
pgm_options.o: pgm_options.c mkdio.h config.h
$(CC) -I. -c pgm_options.c
diff --git a/VERSION b/VERSION
index ac2cdeb..cd57a8b 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.1.3
+2.1.5
diff --git a/configure.inc b/configure.inc
index 458dd1e..8dd57ad 100755
--- a/configure.inc
+++ b/configure.inc
@@ -387,9 +387,11 @@ EOF
if [ $status -eq 0 ]; then
if $AC_CC -x c /dev/null -dM -E 2>&1 | grep '__clang__' >/dev/null; then
TLOG " yuck, you're using clang"
+ IS_CLANG=T
IS_BROKEN_CC=T
elif $AC_CC -v 2>&1 | grep 'gcc version' >/dev/null; then
TLOG " oh ick, it looks like gcc"
+ IS_GCC=T
IS_BROKEN_CC=T
else
TLOG " ok"
@@ -425,8 +427,6 @@ EOF
AC_FAIL " does not compile code properly"
fi
- AC_SUB 'CC' "$AC_CC"
-
__remove ngc$$ ngc$$.c ngc$$.o
return $status
@@ -940,6 +940,7 @@ AC_OUTPUT () {
AC_SUB 'LIBS' "$AC_LIBS"
AC_SUB 'CONFIGURE_FILES' "$__config_files"
AC_SUB 'GENERATED_FILES' "$*"
+ AC_SUB 'CC' "$AC_CC"
AC_SUB 'CFLAGS' "$AC_CFLAGS"
AC_SUB 'LDFLAGS' "$AC_LDFLAGS"
AC_SUB 'srcdir' "$AC_SRCDIR"
@@ -1214,31 +1215,16 @@ AC_COMPILER_PIC () {
return $__rc
}
-#
-# AC_CC_SHLIBS checks if the C compiler can produce shared libraries
-# and if it can writes a librarian that handles those libraries for us.
-#
-AC_CC_SHLIBS () {
- AC_PROG_CC || AC_FAIL "Need a C compiler to build shared libraries"
- AC_PROG_LN_S || AC_FAIL "Need to be able to make symbolic links for shared libraries"
- AC_PROG_INSTALL || AC_FAIL "Need an install program to install shared libraries"
- LOGN "checking whether the C compiler can build shared libraries "
-
- echo "int some_variable = 0;" > ngc$$.c
- if $AC_CC $AC_PICFLAG -shared -o ngc$$.so ngc$$.c; then
- AC_SUB LD_LIBRARY_PATH LD_LIBRARY_PATH
- # -Wl option probably works, but be paranoid anyway
- _VFLAGS="$AC_PICFLAG -shared -Wl,-soname,ngc$$.so.1"
- if $AC_CC $_VFLAGS -o ngc$$.so ngc$$.c; then
- USE_SONAME=T
- fi
- LDCONFIG=`AC_PATH=/sbin:/usr/sbin:/usr/local/sbin acLookFor ldconfig`
- __config_files="$__config_files librarian.sh"
- cat > librarian.sh << EOF
+# generate a macosX librarian
+#
+__AC_MACOS_LIBRARIAN() {
+ AC_SUB LD_LIBRARY_PATH DYLD_LIBRARY_PATH
+ __config_files="$__config_files librarian.sh"
+ cat > librarian.sh << EOF
#! /bin/sh
#
-# Build ELF shared libraries, hiding (some) ickiness from the makefile
+# Build MacOS shared libraries, hiding (some) ickiness from the makefile
ACTION=\$1; shift
LIBRARY=\$1; shift
@@ -1247,41 +1233,43 @@ eval \`awk -F. '{ printf "MAJOR=%d\n", \$1;
printf "VERSION=%d.%d.%d\n", \$1, \$2, \$3; }' \$1\`
shift
-LIBNAME=\$LIBRARY.so
-FULLNAME=\$LIBNAME.\$VERSION
+LIBNAME=\$LIBRARY.dylib
+FULLNAME=\$LIBNAME
case "\$ACTION" in
-make) FLAGS="$AC_CFLAGS -shared"
- unset VFLAGS
- test "$USE_SONAME" && VFLAGS="-Wl,-soname,\$LIBNAME.\$MAJOR"
+make) FLAGS="$AC_CFLAGS -dynamiclib"
+ VFLAGS="-current_version \$VERSION -compatibility_version \$MAJOR"
- rm -f \$LIBRARY \$LIBNAME \$LIBNAME.\$MAJOR
+ rm -f \$LIBRARY
if $AC_CC \$FLAGS \$VFLAGS -o \$FULLNAME "\$@"; then
$PROG_LN_S \$FULLNAME \$LIBRARY
- $PROG_LN_S \$FULLNAME \$LIBNAME
- $PROG_LN_S \$FULLNAME \$LIBNAME.\$MAJOR
fi
;;
-files) echo "\$FULLNAME" "\$LIBNAME" "\$LIBNAME.\$MAJOR"
+files) echo "\$FULLNAME"
;;
install)$PROG_INSTALL -c \$FULLNAME "\$1"
- $PROG_LN_S -f \$FULLNAME \$1/\$LIBNAME.\$MAJOR
- $PROG_LN_S -f \$FULLNAME \$1/\$LIBNAME
- test "$LDCONFIG" && $LDCONFIG "\$1"
;;
esac
EOF
- chmod +x librarian.sh
- LOG "(yes; -shared)"
- __rc=0
- elif $AC_CC $AC_PICFLAG -dynamiclib -o ngc$$.so ngc$$.c; then
- # macosx
- AC_SUB LD_LIBRARY_PATH DYLD_LIBRARY_PATH
- __config_files="$__config_files librarian.sh"
- cat > librarian.sh << EOF
+ chmod +x librarian.sh
+}
+
+
+# Generate an ELF librarian (for Linux, freebsd)
+#
+__AC_ELF_LIBRARIAN() {
+ AC_SUB LD_LIBRARY_PATH LD_LIBRARY_PATH
+ # -Wl option probably works, but be paranoid anyway
+ _VFLAGS="$AC_PICFLAG -shared -Wl,-soname,ngc$$.so.1"
+ if $AC_CC $_VFLAGS -o ngc$$.so ngc$$.c; then
+ USE_SONAME=T
+ fi
+ LDCONFIG=`AC_PATH=/sbin:/usr/sbin:/usr/local/sbin acLookFor ldconfig`
+ __config_files="$__config_files librarian.sh"
+ cat > librarian.sh << EOF
#! /bin/sh
#
-# Build MacOS shared libraries, hiding (some) ickiness from the makefile
+# Build ELF shared libraries, hiding (some) ickiness from the makefile
ACTION=\$1; shift
LIBRARY=\$1; shift
@@ -1290,26 +1278,60 @@ eval \`awk -F. '{ printf "MAJOR=%d\n", \$1;
printf "VERSION=%d.%d.%d\n", \$1, \$2, \$3; }' \$1\`
shift
-LIBNAME=\$LIBRARY.dylib
-FULLNAME=\$LIBNAME
+LIBNAME=\$LIBRARY.so
+FULLNAME=\$LIBNAME.\$VERSION
case "\$ACTION" in
-make) FLAGS="$AC_CFLAGS -dynamiclib"
- VFLAGS="-current_version \$VERSION -compatibility_version \$MAJOR"
+make) FLAGS="$AC_CFLAGS -shared"
+ unset VFLAGS
+ test "$USE_SONAME" && VFLAGS="-Wl,-soname,\$LIBNAME.\$MAJOR"
- rm -f \$LIBRARY
+ rm -f \$LIBRARY \$LIBNAME \$LIBNAME.\$MAJOR
if $AC_CC \$FLAGS \$VFLAGS -o \$FULLNAME "\$@"; then
$PROG_LN_S \$FULLNAME \$LIBRARY
+ $PROG_LN_S \$FULLNAME \$LIBNAME
+ $PROG_LN_S \$FULLNAME \$LIBNAME.\$MAJOR
fi
;;
-files) echo "\$FULLNAME"
+files) echo "\$FULLNAME" "\$LIBNAME" "\$LIBNAME.\$MAJOR"
;;
install)$PROG_INSTALL -c \$FULLNAME "\$1"
+ $PROG_LN_S -f \$FULLNAME \$1/\$LIBNAME.\$MAJOR
+ $PROG_LN_S -f \$FULLNAME \$1/\$LIBNAME
+ test "$LDCONFIG" && $LDCONFIG "\$1"
;;
esac
EOF
- chmod +x librarian.sh
- LOG "(yes; macos dylib)"
+ chmod +x librarian.sh
+}
+
+
+#
+# AC_CC_SHLIBS checks if the C compiler can produce shared libraries
+# and if it can writes a librarian that handles those libraries for us.
+#
+AC_CC_SHLIBS () {
+ AC_PROG_CC || AC_FAIL "Need a C compiler to build shared libraries"
+ AC_PROG_LN_S || AC_FAIL "Need to be able to make symbolic links for shared libraries"
+ AC_PROG_INSTALL || AC_FAIL "Need an install program to install shared libraries"
+ LOGN "checking whether the C compiler can build shared libraries "
+
+ echo "int some_variable = 0;" > ngc$$.c
+
+ if uname -a | grep Darwin >/dev/null; then
+ # Claims to be macos?
+ if $AC_CC $AC_PICFLAG -dynamiclib -o ngc$$.so ngc$$.c; then
+ __AC_MACOS_LIBRARIAN
+
+ LOG "(yes; macos dylib)"
+ __rc=0
+ else
+ LOG "(no)"
+ __rc=1
+ fi
+ elif $AC_CC $AC_PICFLAG -shared -o ngc$$.so ngc$$.c; then
+ __AC_ELF_LIBRARIAN
+ LOG "(yes; -shared)"
__rc=0
else
LOG "(no)"
diff --git a/configure.sh b/configure.sh
index 43ef971..44c8986 100755
--- a/configure.sh
+++ b/configure.sh
@@ -62,10 +62,21 @@ AC_PROG_CC
test "$TRY_SHARED" && AC_COMPILER_PIC && AC_CC_SHLIBS
-case "$AC_CC $AC_CFLAGS" in
-*-Wall*) AC_DEFINE 'while(x)' 'while( (x) != 0 )'
- AC_DEFINE 'if(x)' 'if( (x) != 0 )' ;;
-esac
+if [ "IS_BROKEN_CC" ]; then
+ case "$AC_CC $AC_CFLAGS" in
+ *-pedantic*) ;;
+ *) # hack around deficiencies in gcc and clang
+ #
+ AC_DEFINE 'while(x)' 'while( (x) != 0 )'
+ AC_DEFINE 'if(x)' 'if( (x) != 0 )'
+
+ if [ "$IS_CLANG" ]; then
+ AC_CC="$AC_CC -Wno-implicit-int"
+ elif [ "$IS_GCC" ]; then
+ AC_CC="$AC_CC -Wno-return-type -Wno-implicit-int"
+ fi ;;
+ esac
+fi
AC_PROG ar || AC_FAIL "$TARGET requires ar"
AC_PROG ranlib
diff --git a/cstring.h b/cstring.h
index 96ad841..a03ba2c 100644
--- a/cstring.h
+++ b/cstring.h
@@ -27,9 +27,9 @@
#define DELETE(x) ALLOCATED(x) ? (free(T(x)), S(x) = (x).alloc = 0) \
: ( S(x) = 0 )
#define CLIP(t,i,sz) \
- ( ((i) >= 0) && ((sz) > 0) && (((i)+(sz)) <= S(t)) ) ? \
+ S(t) -= ( ((i) >= 0) && ((sz) > 0) && (((i)+(sz)) <= S(t)) ) ? \
(memmove(&T(t)[i], &T(t)[i+sz], (S(t)-(i+sz)+1)*sizeof(T(t)[0])), \
- S(t) -= (sz)) : -1
+ (sz)) : 0
#define RESERVE(x, sz) T(x) = ((x).alloc > S(x) + (sz) \
? T(x) \
diff --git a/flags.c b/flags.c
index 5bf206c..cc1c589 100644
--- a/flags.c
+++ b/flags.c
@@ -29,6 +29,7 @@ static struct flagnames flagnames[] = {
{ MKD_NOALPHALIST, "!ALPHALIST" },
{ MKD_NODLIST, "!DLIST" },
{ MKD_EXTRA_FOOTNOTE, "FOOTNOTE" },
+ { MKD_NOSTYLE, "!STYLE" },
};
#define NR(x) (sizeof x/sizeof x[0])
diff --git a/generate.c b/generate.c
index 5c0b179..b17ae39 100644
--- a/generate.c
+++ b/generate.c
@@ -183,9 +183,10 @@ Qem(MMIOT *f, char c, int count)
/* generate html from a markup fragment
*/
void
-___mkd_reparse(char *bfr, int size, int flags, MMIOT *f)
+___mkd_reparse(char *bfr, int size, int flags, MMIOT *f, char *esc)
{
MMIOT sub;
+ struct escaped e;
___mkd_initmmiot(&sub, f->footnotes);
@@ -193,6 +194,14 @@ ___mkd_reparse(char *bfr, int size, int flags, MMIOT *f)
sub.cb = f->cb;
sub.ref_prefix = f->ref_prefix;
+ if ( esc ) {
+ sub.esc = &e;
+ e.up = f->esc;
+ e.text = esc;
+ }
+ else
+ sub.esc = f->esc;
+
push(bfr, size, &sub);
EXPAND(sub.in) = 0;
S(sub.in)--;
@@ -207,6 +216,23 @@ ___mkd_reparse(char *bfr, int size, int flags, MMIOT *f)
/*
+ * check the escape list for special cases
+ */
+static int
+escaped(MMIOT *f, char c)
+{
+ struct escaped *thing = f->esc;
+
+ while ( thing ) {
+ if ( strchr(thing->text, c) )
+ return 1;
+ thing = thing->up;
+ }
+ return 0;
+}
+
+
+/*
* write out a url, escaping problematic characters
*/
static void
@@ -553,7 +579,7 @@ printlinkyref(MMIOT *f, linkytype *tag, char *link, int size)
puturl(link + tag->szpat, size - tag->szpat, f, 0);
}
else
- ___mkd_reparse(link + tag->szpat, size - tag->szpat, MKD_TAGTEXT, f);
+ ___mkd_reparse(link + tag->szpat, size - tag->szpat, MKD_TAGTEXT, f, 0);
Qstring(tag->link_sfx, f);
@@ -585,7 +611,7 @@ extra_linky(MMIOT *f, Cstring text, Footnote *ref)
return 0;
if ( f->flags & IS_LABEL )
- ___mkd_reparse(T(text), S(text), linkt.flags, f);
+ ___mkd_reparse(T(text), S(text), linkt.flags, f, 0);
else {
ref->flags |= REFERENCED;
ref->refnumber = ++ f->reference;
@@ -604,7 +630,8 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref)
{
linkytype *tag;
- if ( image || (ref == 0) )
+
+ if ( image )
tag = &imaget;
else if ( tag = pseudo(ref->link) ) {
if ( f->flags & (MKD_NO_EXT|MKD_SAFELINK) )
@@ -624,7 +651,7 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref)
return 0;
if ( f->flags & IS_LABEL )
- ___mkd_reparse(T(text), S(text), tag->flags, f);
+ ___mkd_reparse(T(text), S(text), tag->flags, f, 0);
else if ( tag->link_pfx ) {
printlinkyref(f, tag, T(ref->link), S(ref->link));
@@ -635,12 +662,12 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref)
if ( S(ref->title) ) {
Qstring(" title=\"", f);
- ___mkd_reparse(T(ref->title), S(ref->title), MKD_TAGTEXT, f);
+ ___mkd_reparse(T(ref->title), S(ref->title), MKD_TAGTEXT, f, 0);
Qchar('"', f);
}
Qstring(tag->text_pfx, f);
- ___mkd_reparse(T(text), S(text), tag->flags, f);
+ ___mkd_reparse(T(text), S(text), tag->flags, f, 0);
Qstring(tag->text_sfx, f);
}
else
@@ -707,8 +734,6 @@ linkylinky(int image, MMIOT *f)
else
status = linkyformat(f, name, image, ref);
}
- else if ( f->flags & IS_LABEL )
- status = linkyformat(f, name, image, 0);
}
}
}
@@ -810,6 +835,8 @@ code(MMIOT *f, char *s, int length)
for ( i=0; i < length; i++ )
if ( (c = s[i]) == 003) /* ^C: expand back to 2 spaces */
Qstring(" ", f);
+ else if ( c == '\\' && (i < length-1) && escaped(f, s[i+1]) )
+ cputc(s[++i], f);
else
cputc(c, f);
} /* code */
@@ -821,7 +848,7 @@ static void
delspan(MMIOT *f, int size)
{
Qstring("<del>", f);
- ___mkd_reparse(cursor(f)-1, size, 0, f);
+ ___mkd_reparse(cursor(f)-1, size, 0, f, 0);
Qstring("</del>", f);
}
@@ -1058,7 +1085,7 @@ islike(MMIOT *f, char *s)
int len;
int i;
- if ( s[0] == '<' ) {
+ if ( s[0] == '|' ) {
if ( !isthisnonword(f, -1) )
return 0;
++s;
@@ -1067,7 +1094,7 @@ islike(MMIOT *f, char *s)
if ( !(len = strlen(s)) )
return 0;
- if ( s[len-1] == '>' ) {
+ if ( s[len-1] == '|' ) {
if ( !isthisnonword(f,len-1) )
return 0;
len--;
@@ -1086,13 +1113,13 @@ static struct smarties {
char *entity;
int shift;
} smarties[] = {
- { '\'', "'s>", "rsquo", 0 },
- { '\'', "'t>", "rsquo", 0 },
- { '\'', "'re>", "rsquo", 0 },
- { '\'', "'ll>", "rsquo", 0 },
- { '\'', "'ve>", "rsquo", 0 },
- { '\'', "'m>", "rsquo", 0 },
- { '\'', "'d>", "rsquo", 0 },
+ { '\'', "'s|", "rsquo", 0 },
+ { '\'', "'t|", "rsquo", 0 },
+ { '\'', "'re|", "rsquo", 0 },
+ { '\'', "'ll|", "rsquo", 0 },
+ { '\'', "'ve|", "rsquo", 0 },
+ { '\'', "'m|", "rsquo", 0 },
+ { '\'', "'d|", "rsquo", 0 },
{ '-', "---", "mdash", 2 },
{ '-', "--", "ndash", 1 },
{ '.', "...", "hellip", 2 },
@@ -1100,11 +1127,11 @@ static struct smarties {
{ '(', "(c)", "copy", 2 },
{ '(', "(r)", "reg", 2 },
{ '(', "(tm)", "trade", 3 },
- { '3', "<3/4>", "frac34", 2 },
- { '3', "<3/4ths>", "frac34", 2 },
- { '1', "<1/2>", "frac12", 2 },
- { '1', "<1/4>", "frac14", 2 },
- { '1', "<1/4th>", "frac14", 2 },
+ { '3', "|3/4|", "frac34", 2 },
+ { '3', "|3/4ths|", "frac34", 2 },
+ { '1', "|1/2|", "frac12", 2 },
+ { '1', "|1/4|", "frac14", 2 },
+ { '1', "|1/4th|", "frac14", 2 },
{ '&', "", 0, 3 },
} ;
#define NRSMART ( sizeof smarties / sizeof smarties[0] )
@@ -1146,7 +1173,7 @@ smartypants(int c, int *flags, MMIOT *f)
break;
else if ( c == '\'' && peek(f, j+1) == '\'' ) {
Qstring("“", f);
- ___mkd_reparse(cursor(f)+1, j-2, 0, f);
+ ___mkd_reparse(cursor(f)+1, j-2, 0, f, 0);
Qstring("”", f);
shift(f,j+1);
return 1;
@@ -1268,7 +1295,7 @@ text(MMIOT *f)
shift(f,len);
}
Qstring("<sup>",f);
- ___mkd_reparse(sup, len, 0, f);
+ ___mkd_reparse(sup, len, 0, f, "()");
Qstring("</sup>", f);
}
break;
@@ -1327,16 +1354,16 @@ text(MMIOT *f)
Qchar(c, f);
break;
- case '>': case '#': case '.': case '-':
- case '+': case '{': case '}': case ']':
- case '!': case '[': case '*': case '_':
- case '\\':case '(': case ')':
- case '`': Qchar(c, f);
+ case EOF: Qchar('\\', f);
break;
- default:
- Qchar('\\', f);
- if ( c != EOF )
- shift(f,-1);
+
+ default: if ( escaped(f,c) ||
+ strchr(">#.-+{}]![*_\\()`", c) )
+ Qchar(c, f);
+ else {
+ Qchar('\\', f);
+ shift(f, -1);
+ }
break;
}
break;
@@ -1429,7 +1456,7 @@ splat(Line *p, char *block, Istring align, int force, MMIOT *f)
Qprintf(f, "<%s%s>",
block,
alignments[ (colno < S(align)) ? T(align)[colno] : a_NONE ]);
- ___mkd_reparse(T(p->text)+first, idx-first, 0, f);
+ ___mkd_reparse(T(p->text)+first, idx-first, 0, f, "|");
Qprintf(f, "</%s>\n", block);
idx++;
colno++;
@@ -1613,7 +1640,7 @@ definitionlist(Paragraph *p, MMIOT *f)
for ( ; p ; p = p->next) {
for ( tag = p->text; tag; tag = tag->next ) {
Qstring("<dt>", f);
- ___mkd_reparse(T(tag->text), S(tag->text), 0, f);
+ ___mkd_reparse(T(tag->text), S(tag->text), 0, f, 0);
Qstring("</dt>\n", f);
}
diff --git a/github_flavoured.c b/github_flavoured.c
new file mode 100644
index 0000000..12ed609
--- /dev/null
+++ b/github_flavoured.c
@@ -0,0 +1,100 @@
+
+/*
+ * github_flavoured -- implement the obnoxious "returns are hard newlines"
+ * feature in github flavoured markdown.
+ *
+ * Copyright (C) 2012 David L Parsons.
+ * The redistribution terms are provided in the COPYRIGHT file that must
+ * be distributed with this source code.
+ */
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "cstring.h"
+#include "markdown.h"
+#include "amalloc.h"
+
+/* build a Document from any old input.
+ */
+typedef int (*getc_func)(void*);
+
+Document *
+gfm_populate(getc_func getc, void* ctx, int flags)
+{
+ Cstring line;
+ Document *a = __mkd_new_Document();
+ int c;
+ int pandoc = 0;
+
+ if ( !a ) return 0;
+
+ a->tabstop = (flags & MKD_TABSTOP) ? 4 : TABSTOP;
+
+ CREATE(line);
+
+ while ( (c = (*getc)(ctx)) != EOF ) {
+ if ( c == '\n' ) {
+ if ( pandoc != EOF && pandoc < 3 ) {
+ if ( S(line) && (T(line)[0] == '%') )
+ pandoc++;
+ else
+ pandoc = EOF;
+ }
+
+ if (pandoc == EOF) {
+ EXPAND(line) = ' ';
+ EXPAND(line) = ' ';
+ }
+ __mkd_enqueue(a, &line);
+ S(line) = 0;
+ }
+ else if ( isprint(c) || isspace(c) || (c & 0x80) )
+ EXPAND(line) = c;
+ }
+
+ if ( S(line) )
+ __mkd_enqueue(a, &line);
+
+ DELETE(line);
+
+ if ( (pandoc == 3) && !(flags & (MKD_NOHEADER|MKD_STRICT)) ) {
+ /* the first three lines started with %, so we have a header.
+ * clip the first three lines out of content and hang them
+ * off header.
+ */
+ Line *headers = T(a->content);
+
+ a->title = headers; __mkd_header_dle(a->title);
+ a->author= headers->next; __mkd_header_dle(a->author);
+ a->date = headers->next->next; __mkd_header_dle(a->date);
+
+ T(a->content) = headers->next->next->next;
+ }
+
+ return a;
+}
+
+
+/* convert a block of text into a linked list
+ */
+Document *
+gfm_string(const char *buf, int len, DWORD flags)
+{
+ struct string_stream about;
+
+ about.data = buf;
+ about.size = len;
+
+ return gfm_populate((getc_func)__mkd_io_strget, &about, flags & INPUT_MASK);
+}
+
+
+/* convert a file into a linked list
+ */
+Document *
+gfm_in(FILE *f, DWORD flags)
+{
+ return gfm_populate((getc_func)fgetc, f, flags & INPUT_MASK);
+}
diff --git a/main.c b/main.c
index ff5f581..e052c38 100644
--- a/main.c
+++ b/main.c
@@ -18,6 +18,7 @@
#include "config.h"
#include "amalloc.h"
#include "pgm_options.h"
+#include "tags.h"
#if HAVE_LIBGEN_H
#include <libgen.h>
@@ -66,9 +67,12 @@ main(int argc, char **argv)
mkd_flag_t flags = 0;
int debug = 0;
int toc = 0;
+ int content = 1;
int version = 0;
int with_html5 = 0;
+ int styles = 0;
int use_mkd_line = 0;
+ int github_flavoured = 0;
char *extra_footnote_prefix = 0;
char *urlflags = 0;
char *text = 0;
@@ -83,7 +87,7 @@ main(int argc, char **argv)
pgm = basename(argv[0]);
opterr = 1;
- while ( (opt=getopt(argc, argv, "5b:C:df:E:F:o:s:t:TV")) != EOF ) {
+ while ( (opt=getopt(argc, argv, "5b:C:df:E:F:Gno:s:St:TV")) != EOF ) {
switch (opt) {
case '5': with_html5 = 1;
break;
@@ -109,13 +113,19 @@ main(int argc, char **argv)
else if ( !set_flag(&flags, optarg) )
complain("unknown option <%s>", optarg);
break;
+ case 'G': github_flavoured = 1;
+ break;
+ case 'n': content = 0;
+ break;
+ case 's': text = optarg;
+ break;
+ case 'S': styles = 1;
+ break;
case 't': text = optarg;
use_mkd_line = 1;
break;
case 'T': toc = 1;
break;
- case 's': text = optarg;
- break;
case 'C': extra_footnote_prefix = optarg;
break;
case 'o': if ( ofile ) {
@@ -154,7 +164,10 @@ main(int argc, char **argv)
rc = mkd_generateline( text, strlen(text), stdout, flags);
else {
if ( text ) {
- if ( (doc = mkd_string(text, strlen(text), flags)) == 0 ) {
+ doc = github_flavoured ? gfm_string(text, strlen(text), flags)
+ : mkd_string(text, strlen(text), flags) ;
+
+ if ( !doc ) {
perror(text);
exit(1);
}
@@ -164,7 +177,9 @@ main(int argc, char **argv)
perror(argv[0]);
exit(1);
}
- if ( (doc = mkd_in(stdin,flags)) == 0 ) {
+
+ doc = github_flavoured ? gfm_in(stdin,flags) : mkd_in(stdin,flags);
+ if ( !doc ) {
perror(argc ? argv[0] : "stdin");
exit(1);
}
@@ -184,9 +199,12 @@ main(int argc, char **argv)
rc = 1;
if ( mkd_compile(doc, flags) ) {
rc = 0;
+ if ( styles )
+ mkd_generatecss(doc, stdout);
if ( toc )
mkd_generatetoc(doc, stdout);
- mkd_generatehtml(doc, stdout);
+ if ( content )
+ mkd_generatehtml(doc, stdout);
mkd_cleanup(doc);
}
}
diff --git a/markdown.1 b/markdown.1
index c99e57f..4bd69e1 100644
--- a/markdown.1
+++ b/markdown.1
@@ -15,7 +15,9 @@
.Op Fl C Ar prefix
.Op Fl F Pa bitmap
.Op Fl f Ar flags
+.Op Fl n
.Op Fl o Pa file
+.Op Fl S
.Op Fl s Pa text
.Op Fl t Pa text
.Op Pa textfile
@@ -107,6 +109,8 @@ Allow alphabetic lists.
Allow definition lists.
.It Ar footnote
Allow markdown extra-style footnotes.
+.It Ar styles
+Extract <style> blocks from the output.
.El
.Pp
As an example, the option
@@ -123,6 +127,13 @@ described in
.Xr markdown 3
(the flag values are defined in
.Pa mkdio.h )
+.It Fl n
+Don't write generated html.
+.It Fl o Pa file
+Write the generated html to
+.Pa file .
+.It Fl S
+output <style> blocks.
.It Fl V
Show the version# and compile-time configuration data.
.Pp
@@ -138,9 +149,6 @@ was configured to use the specified tabstop.
.It Fl VV
Show the version#, the compile-time configuration, and the
run-time configuration.
-.It Fl o Pa file
-Write the generated html to
-.Pa file .
.It Fl t Ar text
Use
.Xr mkd_text 3
diff --git a/markdown.c b/markdown.c
index 2a8cc65..5a65679 100644
--- a/markdown.c
+++ b/markdown.c
@@ -188,7 +188,8 @@ checkline(Line *l)
int eol, i;
int dashes = 0, spaces = 0,
equals = 0, underscores = 0,
- stars = 0, tildes = 0;
+ stars = 0, tildes = 0,
+ backticks = 0;
l->flags |= CHECKED;
l->kind = chk_text;
@@ -210,12 +211,15 @@ checkline(Line *l)
case '=': equals = 1; break;
case '_': underscores = 1; break;
case '*': stars = 1; break;
+#if WITH_FENCED_CODE
case '~': tildes = 1; break;
+ case '`': backticks = 1; break;
+#endif
default: return;
}
}
- if ( dashes + equals + underscores + stars + tildes > 1 )
+ if ( dashes + equals + underscores + stars + tildes + backticks > 1 )
return;
if ( spaces ) {
@@ -227,7 +231,10 @@ checkline(Line *l)
if ( stars || underscores ) { l->kind = chk_hr; }
else if ( dashes ) { l->kind = chk_dash; }
else if ( tildes ) { l->kind = chk_tilde; }
+#if WITH_FENCED_CODE
else if ( equals ) { l->kind = chk_equal; }
+ else if ( backticks ) { l->kind = chk_backtick; }
+#endif
}
@@ -449,7 +456,7 @@ is_extra_dt(Line *t, int *clip)
{
#if USE_EXTRA_DL
- if ( t && t->next && T(t->text)[0] != '='
+ if ( t && t->next && S(t->text) && T(t->text)[0] != '='
&& T(t->text)[S(t->text)-1] != '=') {
Line *x;
@@ -599,12 +606,15 @@ codeblock(Paragraph *p)
#ifdef WITH_FENCED_CODE
static int
-iscodefence(Line *r, int size)
+iscodefence(Line *r, int size, line_type kind)
{
if ( !(r->flags & CHECKED) )
checkline(r);
- return (r->kind == chk_tilde) && (r->count >= size);
+ if ( kind )
+ return (r->kind == kind) && (r->count >= size);
+ else
+ return (r->kind == chk_tilde || r->kind == chk_backtick) && (r->count >= size);
}
static Paragraph *
@@ -617,14 +627,14 @@ fencedcodeblock(ParagraphRoot *d, Line **ptr)
/* don't allow zero-length code fences
*/
- if ( (first->next == 0) || iscodefence(first->next, first->count) )
+ if ( (first->next == 0) || iscodefence(first->next, first->count, 0) )
return 0;
/* find the closing fence, discard the fences,
* return a Paragraph with the contents
*/
for ( r = first; r && r->next; r = r->next )
- if ( iscodefence(r->next, first->count) ) {
+ if ( iscodefence(r->next, first->count, first->kind) ) {
(*ptr) = r->next->next;
ret = Pp(d, first->next, CODE);
___mkd_freeLine(first);
@@ -872,7 +882,7 @@ definition_block(Paragraph *top, int clip, MMIOT *f, int kind)
if ( (text = skipempty(q->next)) == 0 )
break;
- if (( para = (text != q->next) ))
+ if ( para = (text != q->next) )
___mkd_freeLineRange(q, text);
q->next = 0;
@@ -895,7 +905,7 @@ definition_block(Paragraph *top, int clip, MMIOT *f, int kind)
if ( (q = skipempty(text)) == 0 )
break;
- if (( para = (q != text) )) {
+ if ( para = (q != text) ) {
Line anchor;
anchor.next = text;
@@ -1085,6 +1095,7 @@ compile_document(Line *ptr, MMIOT *f)
while ( ptr ) {
if ( !(f->flags & MKD_NOHTML) && (tag = isopentag(ptr)) ) {
+ int blocktype;
/* If we encounter a html/style block, compile and save all
* of the cached source BEFORE processing the html/style.
*/
@@ -1094,7 +1105,12 @@ compile_document(Line *ptr, MMIOT *f)
p->down = compile(T(source), 1, f);
T(source) = E(source) = 0;
}
- p = Pp(&d, ptr, strcmp(tag->id, "STYLE") == 0 ? STYLE : HTML);
+
+ if ( f->flags & MKD_NOSTYLE )
+ blocktype = HTML;
+ else
+ blocktype = strcmp(tag->id, "STYLE") == 0 ? STYLE : HTML;
+ p = Pp(&d, ptr, blocktype);
ptr = htmlblock(p, tag, &unclosed);
if ( unclosed ) {
p->typ = SOURCE;
@@ -1212,7 +1228,7 @@ compile(Line *ptr, int toplevel, MMIOT *f)
ptr = codeblock(p);
}
#if WITH_FENCED_CODE
- else if ( iscodefence(ptr,3) && (p=fencedcodeblock(&d, &ptr)) )
+ else if ( iscodefence(ptr,3,0) && (p=fencedcodeblock(&d, &ptr)) )
/* yay, it's already done */ ;
#endif
else if ( ishr(ptr) ) {
@@ -1221,7 +1237,7 @@ compile(Line *ptr, int toplevel, MMIOT *f)
ptr = ptr->next;
___mkd_freeLine(r);
}
- else if (( list_class = islist(ptr, &indent, f->flags, &list_type) )) {
+ else if ( list_class = islist(ptr, &indent, f->flags, &list_type) ) {
if ( list_class == DL ) {
p = Pp(&d, ptr, DL);
ptr = definition_block(p, indent, f, list_type);
diff --git a/markdown.h b/markdown.h
index 4c7d181..775948a 100644
--- a/markdown.h
+++ b/markdown.h
@@ -23,6 +23,10 @@ typedef struct footnote {
* that all tabs will be expanded to spaces!], and a pointer to
* the next line.
*/
+typedef enum { chk_text, chk_code,
+ chk_hr, chk_dash,
+ chk_tilde, chk_backtick,
+ chk_equal } line_type;
typedef struct line {
Cstring text;
struct line *next;
@@ -31,9 +35,7 @@ typedef struct line {
#define PIPECHAR 0x01 /* line contains a | */
#define CHECKED 0x02
- enum { chk_text, chk_code,
- chk_hr, chk_dash,
- chk_tilde, chk_equal } kind;
+ line_type kind;
int count;
} Line;
@@ -79,6 +81,12 @@ typedef struct callback_data {
} Callback_data;
+struct escaped {
+ char *text;
+ struct escaped *up;
+} ;
+
+
/* a magic markdown io thing holds all the data structures needed to
* do the backend processing of a markdown document
*/
@@ -88,6 +96,7 @@ typedef struct mmiot {
Qblock Q;
int isp;
int reference;
+ struct escaped *esc;
char *ref_prefix;
STRING(Footnote) *footnotes;
DWORD flags;
@@ -113,6 +122,7 @@ typedef struct mmiot {
#define MKD_NOALPHALIST 0x00080000
#define MKD_NODLIST 0x00100000
#define MKD_EXTRA_FOOTNOTE 0x00200000
+#define MKD_NOSTYLE 0x00400000
#define IS_LABEL 0x08000000
#define USER_FLAGS 0x0FFFFFFF
#define INPUT_MASK (MKD_NOHEADER|MKD_TABSTOP)
@@ -145,6 +155,16 @@ typedef struct document {
} Document;
+/*
+ * economy FILE-type structure for pulling characters out of a
+ * fixed-length string.
+ */
+struct string_stream {
+ const char *data; /* the unread data */
+ int size; /* and how much is there? */
+} ;
+
+
extern int mkd_firstnonblank(Line *);
extern int mkd_compile(Document *, DWORD);
extern int mkd_document(Document *, char **);
@@ -166,6 +186,9 @@ extern void mkd_string_to_anchor(char*,int, mkd_sta_function_t, void*, int);
extern Document *mkd_in(FILE *, DWORD);
extern Document *mkd_string(const char*,int, DWORD);
+extern Document *gfm_in(FILE *, DWORD);
+extern Document *gfm_string(const char*,int, DWORD);
+
extern void mkd_initialize();
extern void mkd_shlib_destructor();
@@ -182,8 +205,14 @@ extern void ___mkd_initmmiot(MMIOT *, void *);
extern void ___mkd_freemmiot(MMIOT *, void *);
extern void ___mkd_freeLineRange(Line *, Line *);
extern void ___mkd_xml(char *, int, FILE *);
-extern void ___mkd_reparse(char *, int, int, MMIOT*);
+extern void ___mkd_reparse(char *, int, int, MMIOT*, char*);
extern void ___mkd_emblock(MMIOT*);
extern void ___mkd_tidy(Cstring *);
+extern Document *__mkd_new_Document();
+extern void __mkd_enqueue(Document*, Cstring *);
+extern void __mkd_header_dle(Line *);
+
+extern int __mkd_io_strget(struct string_stream *);
+
#endif/*_MARKDOWN_D*/
diff --git a/mkd2html.c b/mkd2html.c
index 9ee62e4..42b3770 100644
--- a/mkd2html.c
+++ b/mkd2html.c
@@ -45,7 +45,7 @@ basename(char *path)
{
char *p;
- if (( p = strrchr(path, '/') ))
+ if ( p = strrchr(path, '/') )
return 1+p;
return path;
}
@@ -81,7 +81,7 @@ char **argv;
CREATE(footers);
pgm = basename(argv[0]);
- while ( argc > 2 ) {
+ while ( argc ) {
if ( strcmp(argv[1], "-css") == 0 ) {
EXPAND(css) = argv[2];
argc -= 2;
@@ -97,14 +97,20 @@ char **argv;
argc -= 2;
argv += 2;
}
+ else
+ break;
}
-
- if ( argc > 1 ) {
+ switch ( argc ) {
char *p, *dot;
-
+ case 1:
+ input = stdin;
+ output = stdout;
+ break;
+ case 2:
+ case 3:
+ dest = malloc(strlen(argv[argc-1]) + 6);
source = malloc(strlen(argv[1]) + 6);
- dest = malloc(strlen(argv[1]) + 6);
if ( !(source && dest) )
fail("out of memory allocating name buffers");
@@ -128,10 +134,11 @@ char **argv;
if ( (output = fopen(dest, "w")) == 0 )
fail("can't write to %s", dest);
- }
- else {
- input = stdin;
- output = stdout;
+ break;
+
+ default:
+ fprintf(stderr, "usage: %s [opts] source [dest]\n", pgm);
+ exit(1);
}
if ( (mmiot = mkd_in(input, 0)) == 0 )
diff --git a/mkdio.c b/mkdio.c
index 0bee521..15606aa 100644
--- a/mkdio.c
+++ b/mkdio.c
@@ -18,13 +18,13 @@ typedef ANCHOR(Line) LineAnchor;
/* create a new blank Document
*/
-static Document*
-new_Document()
+Document*
+__mkd_new_Document()
{
Document *ret = calloc(sizeof(Document), 1);
if ( ret ) {
- if (( ret->ctx = calloc(sizeof(MMIOT), 1) )) {
+ if ( ret->ctx = calloc(sizeof(MMIOT), 1) ) {
ret->magic = VALID_DOCUMENT;
return ret;
}
@@ -37,8 +37,8 @@ new_Document()
/* add a line to the markdown input chain, expanding tabs and
* noting the presence of special characters as we go.
*/
-static void
-queue(Document* a, Cstring *line)
+void
+__mkd_enqueue(Document* a, Cstring *line)
{
Line *p = calloc(sizeof *p, 1);
unsigned char c;
@@ -75,8 +75,8 @@ queue(Document* a, Cstring *line)
/* trim leading blanks from a header line
*/
-static void
-header_dle(Line *p)
+void
+__mkd_header_dle(Line *p)
{
CLIP(p->text, 0, 1);
p->dle = mkd_firstnonblank(p);
@@ -91,7 +91,7 @@ Document *
populate(getc_func getc, void* ctx, int flags)
{
Cstring line;
- Document *a = new_Document();
+ Document *a = __mkd_new_Document();
int c;
int pandoc = 0;
@@ -109,7 +109,7 @@ populate(getc_func getc, void* ctx, int flags)
else
pandoc = EOF;
}
- queue(a, &line);
+ __mkd_enqueue(a, &line);
S(line) = 0;
}
else if ( isprint(c) || isspace(c) || (c & 0x80) )
@@ -117,7 +117,7 @@ populate(getc_func getc, void* ctx, int flags)
}
if ( S(line) )
- queue(a, &line);
+ __mkd_enqueue(a, &line);
DELETE(line);
@@ -128,9 +128,9 @@ populate(getc_func getc, void* ctx, int flags)
*/
Line *headers = T(a->content);
- a->title = headers; header_dle(a->title);
- a->author= headers->next; header_dle(a->author);
- a->date = headers->next->next; header_dle(a->date);
+ a->title = headers; __mkd_header_dle(a->title);
+ a->author= headers->next; __mkd_header_dle(a->author);
+ a->date = headers->next->next; __mkd_header_dle(a->date);
T(a->content) = headers->next->next->next;
}
@@ -150,14 +150,8 @@ mkd_in(FILE *f, DWORD flags)
/* return a single character out of a buffer
*/
-struct string_ctx {
- const char *data; /* the unread data */
- int size; /* and how much is there? */
-} ;
-
-
-static int
-strget(struct string_ctx *in)
+int
+__mkd_io_strget(struct string_stream *in)
{
if ( !in->size ) return EOF;
@@ -172,12 +166,12 @@ strget(struct string_ctx *in)
Document *
mkd_string(const char *buf, int len, DWORD flags)
{
- struct string_ctx about;
+ struct string_stream about;
about.data = buf;
about.size = len;
- return populate((getc_func)strget, &about, flags & INPUT_MASK);
+ return populate((getc_func)__mkd_io_strget, &about, flags & INPUT_MASK);
}
@@ -254,7 +248,7 @@ mkd_parse_line(char *bfr, int size, MMIOT *f, int flags)
{
___mkd_initmmiot(f, 0);
f->flags = flags & USER_FLAGS;
- ___mkd_reparse(bfr, size, 0, f);
+ ___mkd_reparse(bfr, size, 0, f, 0);
___mkd_emblock(f);
}
diff --git a/mkdio.h.in b/mkdio.h.in
index 8f5490c..a36ffe8 100644
--- a/mkdio.h.in
+++ b/mkdio.h.in
@@ -12,6 +12,11 @@ typedef @DWORD@ mkd_flag_t;
MMIOT *mkd_in(FILE*,mkd_flag_t); /* assemble input from a file */
MMIOT *mkd_string(const char*,int,mkd_flag_t); /* assemble input from a buffer */
+/* line builder for github flavoured markdown
+ */
+MMIOT *gfm_in(FILE*,mkd_flag_t); /* assemble input from a file */
+MMIOT *gfm_string(const char*,int,mkd_flag_t); /* assemble input from a buffer */
+
void mkd_basename(MMIOT*,char*);
void mkd_initialize();
@@ -100,6 +105,7 @@ void mkd_ref_prefix(MMIOT*, char*);
#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_EMBED MKD_NOLINKS|MKD_NOIMAGE|MKD_TAGTEXT
/* special flags for mkd_in() and mkd_string()
diff --git a/pgm_options.c b/pgm_options.c
index 41c68b1..161917e 100644
--- a/pgm_options.c
+++ b/pgm_options.c
@@ -54,11 +54,14 @@ static struct _opt {
{ "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 },
} ;
#define NR(x) (sizeof x / sizeof x[0])
+typedef int (*stfu)(const void *, const void *);
+
int
sort_by_name(struct _opt *a, struct _opt *b)
{
@@ -78,14 +81,14 @@ show_flags(int byname)
int i;
if ( byname ) {
- qsort(opts, NR(opts), sizeof(opts[0]), sort_by_name);
+ qsort(opts, NR(opts), sizeof(opts[0]), (stfu)sort_by_name);
for (i=0; i < NR(opts); i++)
if ( ! opts[i].skip )
fprintf(stderr, "%16s : %s\n", opts[i].name, opts[i].desc);
}
else {
- qsort(opts, NR(opts), sizeof(opts[0]), sort_by_flag);
+ qsort(opts, NR(opts), sizeof(opts[0]), (stfu)sort_by_flag);
for (i=0; i < NR(opts); i++)
if ( ! opts[i].skip ) {
diff --git a/tests/code.t b/tests/code.t
index 92df860..a5e480a 100644
--- a/tests/code.t
+++ b/tests/code.t
@@ -85,6 +85,21 @@ text text text
code code code?
~~~</p>'
+try 'fenced code blocks with backtick delimiters' \
+'```
+code
+```' \
+'<pre><code>code
+</code></pre>'
+
+try 'fenced code block with mismatched delimters' \
+'```
+code
+~~~' \
+'<p>```
+code
+~~~</p>'
+
fi
summary $0
diff --git a/tests/style.t b/tests/style.t
index 3da3d1c..0dd5265 100644
--- a/tests/style.t
+++ b/tests/style.t
@@ -30,5 +30,7 @@ try 'multiple lines unclosed' "$UNCLOSED" "$RESULT"
try -fnohtml 'unclosed with -fnohtml' '<style>foo' '<p><style>foo</p>'
+try -fnostyle 'disabling style blocks' "$ASK" "$ASK"
+
summary $0
exit $rc
diff --git a/theme.1 b/theme.1
index 3bcf38a..d740b77 100644
--- a/theme.1
+++ b/theme.1
@@ -8,6 +8,8 @@
.Nd create a web page from a template file
.Sh SYNOPSIS
.Nm
+.Op Fl C Pa option-flags
+.Op Fl c Pa options
.Op Fl d Pa root
.Op Fl E
.Op Fl f
diff --git a/theme.c b/theme.c
index 33fb5ec..7000bc6 100644
--- a/theme.c
+++ b/theme.c
@@ -10,6 +10,7 @@
* be distributed with this source code.
*/
#include "config.h"
+#include "pgm_options.h"
#include <stdio.h>
#include <stdlib.h>
@@ -56,7 +57,7 @@ basename(char *path)
{
char *p;
- if (( p = strrchr(path, '/') ))
+ if ( p = strrchr(path, '/') )
return 1+p;
return path;
}
@@ -506,6 +507,7 @@ char **argv;
char *source = "stdin";
FILE *tmplfile;
int opt;
+ mkd_flag_t flags = MKD_TOC;
int force = 0;
MMIOT *doc;
struct stat sourceinfo;
@@ -513,7 +515,7 @@ char **argv;
opterr=1;
pgm = basename(argv[0]);
- while ( (opt=getopt(argc, argv, "Efd:t:p:o:V")) != EOF ) {
+ while ( (opt=getopt(argc, argv, "EfC:c:d:t:p:o:V")) != EOF ) {
switch (opt) {
case 'd': root = optarg;
break;
@@ -525,6 +527,20 @@ char **argv;
break;
case 't': template = optarg;
break;
+ case 'C': if ( strcmp(optarg, "?") == 0 ) {
+ show_flags(0);
+ exit(0);
+ }
+ else
+ flags = strtol(optarg, 0, 0);
+ break;
+ case 'c': if ( strcmp(optarg, "?") == 0 ) {
+ show_flags(1);
+ exit(0);
+ }
+ else if ( !set_flag(&flags, optarg) )
+ fprintf(stderr,"%s: unknown option <%s>", pgm, optarg);
+ break;
case 'o': output = optarg;
break;
case 'V': printf("theme+discount %s\n", markdown_version);
@@ -599,7 +615,7 @@ char **argv;
fail("out of memory");
#endif
- if ( !mkd_compile(doc, MKD_TOC) )
+ if ( !mkd_compile(doc, flags) )
fail("couldn't compile input");
if ( tmplfile )
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/discount.git
More information about the Reproducible-commits
mailing list