Commit 7ab3e174 authored by Alessandro Ghedini's avatar Alessandro Ghedini

New upstream version 2.2.6

parent 0f874ad9
......@@ -50,7 +50,7 @@ Cswrite(Cstring *iot, char *bfr, int size)
/* reparse() into a cstring
*/
void
Csreparse(Cstring *iot, char *buf, int size, int flags)
Csreparse(Cstring *iot, char *buf, int size, mkd_flag_t flags)
{
MMIOT f;
___mkd_initmmiot(&f, 0);
......
......@@ -38,9 +38,28 @@ Configure.sh has a few options that can be set:
--cxx-binding Wrap mkdio.h with (conditional) 'extern "C"' for c++
binding.
3) Installing sample programs and manpages
3) Testing
``make test'' runs discount against a collection of test cases.
4) Installing sample programs and manpages
The standard ``make install'' rule just installs the binaries. If you
want to install the sample programs, they are installed with
``make install.samples''; to install manpages, ``make install.man''.
A shortcut to install everything is ``make install.everything''
5) Assorted platform gotchas
1. On NetBSD (version 8 for certain) running configure.sh by
itself will result in logging output being mixed in with diagnostic
output on the screen instead of having it written to config.log.
If, instead, you do `ksh ./configure.sh`, it will be much less
garbled (the shell defaults all fds > stderr to close on exec,
so my redirecting stdout fails after the first subprocess.)
2. On 9Front (and maybe every other extant plan9 variant) the
system mkfile sets the `T' flag in CFLAGS; there are several
places where I typedef voids to opaque structure pointers and
this makes the build die when it attempts to link anything.
CC=@CC@ -I.
LFLAGS=-L.
CC=@CC@
CFLAGS=@CFLAGS@
LDFLAGS=@LDFLAGS@
AR=@AR@
RANLIB=@RANLIB@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
INSTALL_DIR=@INSTALL_DIR@
INSTALL_DATA=@INSTALL_DATA@
BUILD=$(CC) -I. $(CFLAGS)
LINK=$(CC) -L. $(LDFLAGS)
.c.o:
$(BUILD) -c -o $@ $<
BINDIR=@exedir@
MANDIR=@mandir@
......@@ -17,9 +27,9 @@ 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 \
github_flavoured.o setup.o tags.o html5.o flags.o \
@AMALLOC@ @H1TITLE@
TESTFRAMEWORK=echo cols branch
github_flavoured.o setup.o tags.o html5.o \
@AMALLOC@ @H1TITLE@ flags.o
TESTFRAMEWORK=echo cols branch pandoc_headers
# modules that markdown, makepage, mkd2html, &tc use
COMMON=pgm_options.o gethopt.o notspecial.o
......@@ -29,23 +39,23 @@ MAN3PAGES=mkd-callbacks.3 mkd-functions.3 markdown.3 mkd-line.3
all: $(PGMS) $(SAMPLE_PGMS) $(TESTFRAMEWORK)
install: $(PGMS) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCDIR) $(DESTDIR)$(PKGDIR)
@INSTALL_PROGRAM@ $(PGMS) $(DESTDIR)$(BINDIR)
$(INSTALL_PROGRAM) $(PGMS) $(DESTDIR)$(BINDIR)
./librarian.sh install libmarkdown VERSION $(DESTDIR)$(LIBDIR)
@INSTALL_DATA@ mkdio.h $(DESTDIR)$(INCDIR)
@MK_PKGCONFIG@@INSTALL_DATA@ $(MKDLIB).pc $(DESTDIR)$(PKGDIR)
$(INSTALL_DATA) mkdio.h $(DESTDIR)$(INCDIR)
@MK_PKGCONFIG@$(INSTALL_DATA) $(MKDLIB).pc $(DESTDIR)$(PKGDIR)
install.everything: install install.samples install.man
install.samples: $(SAMPLE_PGMS) install $(DESTDIR)$(BINDIR)
@INSTALL_DIR@ $(DESTDIR)$(MANDIR)/man1
$(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man1
for x in $(SAMPLE_PGMS); do \
@INSTALL_PROGRAM@ $$x $(DESTDIR)$(BINDIR)/$(SAMPLE_PFX)$$x; \
@INSTALL_DATA@ $$x.1 $(DESTDIR)$(MANDIR)/man1/$(SAMPLE_PFX)$$x.1; \
$(INSTALL_PROGRAM) $$x $(DESTDIR)$(BINDIR)/$(SAMPLE_PFX)$$x; \
$(INSTALL_DATA) $$x.1 $(DESTDIR)$(MANDIR)/man1/$(SAMPLE_PFX)$$x.1; \
done
install.man:
@INSTALL_DIR@ $(DESTDIR)$(MANDIR)/man3
@INSTALL_DATA@ $(MAN3PAGES) $(DESTDIR)$(MANDIR)/man3
$(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man3
$(INSTALL_DATA) $(MAN3PAGES) $(DESTDIR)$(MANDIR)/man3
for x in mkd_line mkd_generateline; do \
( echo '.\"' ; echo ".so man3/mkd-line.3" ) > $(DESTDIR)$(MANDIR)/man3/$$x.3;\
done
......@@ -55,27 +65,27 @@ install.man:
for x in mkd_compile mkd_css mkd_generatecss mkd_generatehtml mkd_cleanup mkd_doc_title mkd_doc_author mkd_doc_date; do \
( echo '.\"' ; echo ".so man3/mkd-functions.3" ) > $(DESTDIR)$(MANDIR)/man3/$$x.3; \
done
@INSTALL_DIR@ $(DESTDIR)$(MANDIR)/man7
@INSTALL_DATA@ markdown.7 mkd-extensions.7 $(DESTDIR)$(MANDIR)/man7
@INSTALL_DIR@ $(DESTDIR)$(MANDIR)/man1
@INSTALL_DATA@ markdown.1 $(DESTDIR)$(MANDIR)/man1
$(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man7
$(INSTALL_DATA) markdown.7 mkd-extensions.7 $(DESTDIR)$(MANDIR)/man7
$(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man1
$(INSTALL_DATA) markdown.1 $(DESTDIR)$(MANDIR)/man1
install.everything: install install.man
$(DESTDIR)$(BINDIR):
@INSTALL_DIR@ $(DESTDIR)$(BINDIR)
$(INSTALL_DIR) $(DESTDIR)$(BINDIR)
$(DESTDIR)$(INCDIR):
@INSTALL_DIR@ $(DESTDIR)$(INCDIR)
$(INSTALL_DIR) $(DESTDIR)$(INCDIR)
$(DESTDIR)$(LIBDIR):
@INSTALL_DIR@ $(DESTDIR)$(LIBDIR)
$(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
@MK_PKGCONFIG@$(DESTDIR)$(PKGDIR):
@MK_PKGCONFIG@ @INSTALL_DIR@ $(DESTDIR)$(PKGDIR)
@MK_PKGCONFIG@ $(INSTALL_DIR) $(DESTDIR)$(PKGDIR)
version.o: version.c VERSION branch
$(CC) $(CFLAGS) -DBRANCH=`./branch` -DVERSION=\"`cat VERSION`\" -c version.c
$(BUILD) -DBRANCH=`./branch` -DVERSION=\"`cat VERSION`\" -c version.c
VERSION:
@true
......@@ -85,31 +95,36 @@ tags.o: tags.c cstring.h tags.h blocktags
blocktags: mktags
./mktags > blocktags
mktags: mktags.o
$(LINK) -o mktags mktags.o
# example programs
@THEME@theme: theme.o $(COMMON) $(MKDLIB) mkdio.h
@THEME@ $(CC) $(CFLAGS) $(LFLAGS) -o theme theme.o $(COMMON) -lmarkdown @LIBS@
@THEME@ $(LINK) -o theme theme.o $(COMMON) -lmarkdown @LIBS@
mkd2html: mkd2html.o $(MKDLIB) mkdio.h gethopt.h $(COMMON)
$(CC) $(CFLAGS) $(LFLAGS) -o mkd2html mkd2html.o $(COMMON) -lmarkdown @LIBS@
$(LINK) -o mkd2html mkd2html.o $(COMMON) -lmarkdown @LIBS@
markdown: main.o $(COMMON) $(MKDLIB)
$(CC) $(CFLAGS) $(LFLAGS) -o markdown main.o $(COMMON) -lmarkdown @LIBS@
$(LINK) -o markdown main.o $(COMMON) -lmarkdown @LIBS@
makepage: makepage.c $(COMMON) $(MKDLIB) mkdio.h
$(CC) $(CFLAGS) $(LFLAGS) -o makepage makepage.c $(COMMON) -lmarkdown @LIBS@
makepage.o: makepage.c mkdio.h
$(BUILD) -c makepage.c
makepage: makepage.o $(COMMON) $(MKDLIB)
$(LINK) -o makepage makepage.o $(COMMON) -lmarkdown @LIBS@
pgm_options.o: pgm_options.c mkdio.h config.h
$(CC) $(CFLAGS) -I. -c pgm_options.c
$(BUILD) -c pgm_options.c
notspecial.o: notspecial.c
$(CC) $(CFLAGS) -I. -c notspecial.c
$(BUILD) -c notspecial.c
gethopt.o: gethopt.c
$(CC) $(CFLAGS) -I. -c gethopt.c
$(BUILD) -c gethopt.c
main.o: main.c mkdio.h config.h
$(CC) $(CFLAGS) -I. -c main.c
$(BUILD) -c main.c
$(MKDLIB): $(OBJS)
./librarian.sh make $(MKDLIB) VERSION $(OBJS)
......@@ -118,16 +133,29 @@ verify: echo tools/checkbits.sh
@./echo -n "headers ... "; tools/checkbits.sh && echo "GOOD"
test: $(PGMS) $(TESTFRAMEWORK) verify
@for x in tests/*.t; do \
@for x in $${TESTS:-tests/*.t}; do \
@LD_LIBRARY_PATH@=`pwd` sh $$x || exit 1; \
done
branch: tools/branch.c config.h
$(CC) -o branch tools/branch.c
cols: tools/cols.c config.h
$(CC) -o cols tools/cols.c
echo: tools/echo.c config.h
$(CC) -o echo tools/echo.c
pandoc_headers.o: tools/pandoc_headers.c config.h
$(BUILD) -c -o pandoc_headers.o tools/pandoc_headers.c
pandoc_headers: pandoc_headers.o
$(LINK) -o pandoc_headers pandoc_headers.o $(COMMON) -lmarkdown
branch.o: tools/branch.c config.h
$(BUILD) -c -o branch.o tools/branch.c
branch: branch.o
$(LINK) -o branch branch.o
cols.o: tools/cols.c config.h
$(BUILD) -c -o cols.o tools/cols.c
cols: cols.o
$(LINK) -o cols cols.o
echo.o: tools/echo.c config.h
$(BUILD) -c -o echo.o tools/echo.c
echo: echo.o
$(LINK) -o echo echo.o
clean:
rm -f $(PGMS) $(TESTFRAMEWORK) $(SAMPLE_PGMS) *.o
......
BIN=/$objtype/bin
CC='cc -D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION'
CC='cc'
CFLAGS='-D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION'
markdown:
ape/psh -c 'cd .. && $CC mktags.c -o mktags && ./mktags > blocktags && make'
......
......@@ -17,6 +17,9 @@ set(${PROJECT_NAME}_MAKE_INSTALL ON CACHE BOOL
set(${PROJECT_NAME}_INSTALL_SAMPLES OFF CACHE BOOL
"Set to ON to install sample programs (default is OFF)")
set(${PROJECT_NAME}_ONLY_LIBRARY OFF CACHE BOOL
"Set to ON to only build markdown library (default is OFF)")
# Check headers
include(CheckIncludeFile)
check_include_file(libgen.h HAVE_LIBGEN_H)
......@@ -141,28 +144,30 @@ add_library(libmarkdown
set_target_properties(libmarkdown PROPERTIES
OUTPUT_NAME markdown)
add_library(common OBJECT
"${_ROOT}/pgm_options.c"
"${_ROOT}/gethopt.c")
if(NOT ${PROJECT_NAME}_ONLY_LIBRARY)
add_library(common OBJECT
"${_ROOT}/pgm_options.c"
"${_ROOT}/gethopt.c")
add_executable(markdown
"${_ROOT}/main.c"
$<TARGET_OBJECTS:common>)
add_executable(markdown
"${_ROOT}/main.c"
$<TARGET_OBJECTS:common>)
target_link_libraries(markdown PRIVATE libmarkdown)
target_link_libraries(markdown PRIVATE libmarkdown)
add_executable(mkd2html
"${_ROOT}/mkd2html.c"
$<TARGET_OBJECTS:common>
"${_ROOT}/notspecial.c")
add_executable(mkd2html
"${_ROOT}/mkd2html.c"
$<TARGET_OBJECTS:common>
"${_ROOT}/notspecial.c")
target_link_libraries(mkd2html PRIVATE libmarkdown)
target_link_libraries(mkd2html PRIVATE libmarkdown)
add_executable(makepage
"${_ROOT}/makepage.c"
$<TARGET_OBJECTS:common>)
add_executable(makepage
"${_ROOT}/makepage.c"
$<TARGET_OBJECTS:common>)
target_link_libraries(makepage PRIVATE libmarkdown)
target_link_libraries(makepage PRIVATE libmarkdown)
endif()
if(${PROJECT_NAME}_MAKE_INSTALL)
string(TOLOWER ${PROJECT_NAME} _PACKAGE_NAME)
......
......@@ -364,10 +364,17 @@ AC_PROG_CC () {
test "$AC_CC" && return 0
cat > ngc$$.c << \EOF
#include <stdio.h>
extern void say(void*);
int main()
{
puts("hello, sailor");
say("hello, sailor");
}
EOF
cat > ngf$$.c << \EOF
#include <stdio.h>
void say(char* message)
{
puts(message);
}
EOF
......@@ -394,8 +401,9 @@ EOF
fi
echo "checking out the C compiler"
$AC_CC -o ngc$$ ngc$$.c
$AC_CC -o ngc$$ ngc$$.c ngf$$.c
status=$?
echo "compile status = $status"
TLOGN " ($AC_CC)"
......@@ -429,7 +437,7 @@ EOF
fi
if [ "$LDFLAGS" ]; then
test "$LDFLAGS" && echo "validating LDFLAGS=${LDFLAGS}"
if $AC_CC $CFLAGS $LDFLAGS -o ngc$$ ngc$$.c; then
if $AC_CC $CFLAGS $LDFLAGS -o ngc$$ ngc$$.c ngf$$.c; then
AC_LDFLAGS=${LDFLAGS:-"-g"}
test "$LDFLAGS" && TLOG "LDFLAGS=\"${LDFLAGS}\" are okay"
elif [ "$LDFLAGS" ]; then
......@@ -440,7 +448,7 @@ EOF
fi
# macos-specific(?) test for .dSYM resource directories
$AC_CC $AC_CFLAGS $AC_LDFLAGS -o ngc$$ ngc$$.c
$AC_CC $AC_CFLAGS $AC_LDFLAGS -o ngc$$ ngc$$.c ngf$$.c
ls -dl ngc$$*
test -d ngc$$.dSYM && __MACOS_DSYM=1
......@@ -448,7 +456,7 @@ EOF
AC_FAIL " does not compile code properly"
fi
__remove ngc$$ ngc$$.c ngc$$.o
__remove ngc$$ ngc$$.c ngc$$.o ngf$$.o ngf$$.c
return $status
}
......@@ -468,13 +476,20 @@ acLookFor () {
esac
oldifs="$IFS"
for program in $*; do
IFS=":"
for x in $path; do
if [ $__mode $x/$program -a -f $x/$program ]; then
echo $x/$program
case "$program" in
/*) if [ $__mode $program -a -f $program ]; then
echo $program
break 2
fi
done
fi ;;
*)
IFS=":"
for x in $path; do
if [ $__mode $x/$program -a -f $x/$program ]; then
echo $x/$program
break 3
fi
done ;;
esac
done
IFS="$oldifs"
unset __mode
......@@ -714,7 +729,15 @@ AC_PROG () {
if set | grep -v PROG_$PN >/dev/null; then
TLOGN "looking for $1"
DEST=`acLookFor $1`
__pgm=`eval echo \\$$PN`
if [ "$__pgm" ]; then
TLOGN " (defined as $__pgm)"
DEST=`acLookFor $__pgm`
else
DEST=`acLookFor $1`
fi
if [ "$DEST" ]; then
eval PROG_$PN="$DEST"
AC_SUB $PN $DEST
......@@ -845,7 +868,7 @@ AC_CHECK_ATTRIBUTE() {
AC_DEFINE $__what ' __attribute__((__'$1'__))'
else
TLOG "(no)"
AC_DEFINE $__what ''
AC_DEFINE $__what '/**/'
fi
rm -f ngc$$.o ngc$$.c
}
......@@ -960,7 +983,45 @@ AC_SCALAR_TYPES () {
# TLOG " (defined in WinDef.h)"
# return 0
# fi
# try first to define them with the (allegedly) standard
# unsigned scalar types
#
unset __i;
if AC_QUIET AC_CHECK_HEADERS inttypes.h; then
__i=inttypes.h
elif AC_QUIET AC_CHECK_HEADERS stdint.h; then
__i=stdint.h
fi
if AC_QUIET AC_CHECK_TYPE uint32_t $__i && \
AC_QUIET AC_CHECK_TYPE uint16_t $__i && \
AC_QUIET AC_CHECK_TYPE uint8_t $__i; then
while [ $# -gt 0 ]; do
case "$1" in
sub) ( if [ -z "$__i" ] ; then
echo "s:@SCALAR_HEADER_INCLUDE@::g"
else
echo "s:@SCALAR_HEADER_INCLUDE@:#include <$__i>:g"
fi
echo "s:@DWORD@:uint32_t:g"
echo "s:@WORD@:uint16_t:g"
echo "s:@BYTE@:uint8_t:g" ) >> "$__cwd"/config.sub
;;
*) ( echo "#define DWORD uint32_t"
echo "#define WORD uint16_t"
echo "#define BYTE uint8_t" ) >> "$__cwd"/config.h
;;
esac
shift
done
TLOG " (using standard types ${__i:+in <$__i>})"
return 0
fi
# and if that fails do a brute-force program that does sizeof()ication
# to figure things out
#
cat > ngc$$.c << EOF
#include <stdio.h>
#include <string.h>
......@@ -1010,6 +1071,7 @@ EOF
while [ "$1" ]; do
case "$1" in
sub)if ./ngc$$ sub >> "$__cwd"/config.sub; then
echo "s:@SCALAR_HEADER_INCLUDE@::g" >> "$__cwd"/config.sub
rc=0
fi;;
*) if ./ngc$$ >> "$__cwd"/config.h; then
......
......@@ -59,6 +59,12 @@ VERSION=`cat VERSION`
TARGET=markdown
. ./configure.inc
# if there's a makefile here, it's likely that it's a discount
# makefile and there's bits of an old configuration here. So
# blow everything away before we start the configuration.
test -f Makefile && make spotless 2>/dev/null >/dev/null
AC_INIT $TARGET
AC_SUB 'PACKAGE_NAME' lib$TARGET
AC_SUB 'PACKAGE_VERSION' $VERSION
......
......@@ -72,6 +72,5 @@ typedef STRING(char) Cstring;
extern void Csputc(int, Cstring *);
extern int Csprintf(Cstring *, char *, ...);
extern int Cswrite(Cstring *, char *, int);
extern void Csreparse(Cstring *, char *, int, int);
#endif/*_CSTRING_D*/
......@@ -17,7 +17,12 @@
static char *
onlyifset(Line *l)
{
char *ret = T(l->text) + l->dle;
char *ret;
if ( l->dle < 0 || l->dle >= S(l->text) )
return 0;
ret = T(l->text) + l->dle;
return ret[0] ? ret : 0;
}
......
......@@ -108,7 +108,10 @@ dumptree(Paragraph *pp, Stack *sp, FILE *f)
changepfx(sp, '`');
printpfx(sp, f);
d = fprintf(f, "[%s", Pptype(pp->typ));
if ( pp->typ == HDR )
d += fprintf(f, "[h%d", pp->hnumber);
else
d = fprintf(f, "[%s", Pptype(pp->typ));
if ( pp->ident )
d += fprintf(f, " %s", pp->ident);
......@@ -140,7 +143,7 @@ dumptree(Paragraph *pp, Stack *sp, FILE *f)
int
mkd_dump(Document *doc, FILE *out, int flags, char *title)
mkd_dump(Document *doc, FILE *out, mkd_flag_t flags, char *title)
{
Stack stack;
......
......@@ -2,7 +2,7 @@
#include "markdown.h"
struct flagnames {
DWORD flag;
mkd_flag_t flag;
char *name;
};
......@@ -43,7 +43,7 @@ static struct flagnames flagnames[] = {
void
mkd_flags_are(FILE *f, DWORD flags, int htmlplease)
mkd_flags_are(FILE *f, mkd_flag_t flags, int htmlplease)
{
int i;
int not, set, even=1;
......
......@@ -50,7 +50,7 @@ pushc(char c, MMIOT *f)
/* look <i> characters ahead of the cursor.
*/
static inline unsigned int
static inline int
peek(MMIOT *f, int i)
{
......@@ -180,6 +180,16 @@ Qprintf(MMIOT *f, char *fmt, ...)
}
/* Qanchor() prints out a suitable-for-id-tag version of a string
*/
static void
Qanchor(struct line *p, MMIOT *f)
{
mkd_string_to_anchor(T(p->text), S(p->text),
(mkd_sta_function_t)Qchar, f, 1, f);
}
/* Qem()
*/
static void
......@@ -199,7 +209,7 @@ Qem(MMIOT *f, char c, int count)
/* generate html from a markup fragment
*/
void
___mkd_reparse(char *bfr, int size, int flags, MMIOT *f, char *esc)
___mkd_reparse(char *bfr, int size, mkd_flag_t flags, MMIOT *f, char *esc)
{
MMIOT sub;
struct escaped e;
......@@ -463,7 +473,7 @@ linkyurl(MMIOT *f, int image, Footnote *p)
if ( c == '<' ) {
pull(f);
if ( !(f->flags & MKD_1_COMPAT) )
if ( !is_flag_set(f->flags, MKD_1_COMPAT) )
return linkybroket(f,image,p);
mayneedtotrim=1;
}
......@@ -586,7 +596,7 @@ printlinkyref(MMIOT *f, linkytype *tag, char *link, int size)
{
char *edit;
if ( f->flags & IS_LABEL )
if ( is_flag_set(f->flags, IS_LABEL) )
return;
Qstring(tag->link_pfx, f);
......@@ -681,10 +691,10 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref)
if ( image )
tag = &imaget;
else if ( tag = pseudo(ref->link) ) {
if ( f->flags & (MKD_NO_EXT|MKD_SAFELINK) )
if ( is_flag_set(f->flags, MKD_NO_EXT) || is_flag_set(f->flags, MKD_SAFELINK) )
return 0;
}
else if ( (f->flags & MKD_SAFELINK) && !safelink(ref->link) )
else if ( is_flag_set(f->flags, MKD_SAFELINK) && !safelink(ref->link) )
/* if MKD_SAFELINK, only accept links that are local or
* a well-known protocol
*/
......@@ -695,7 +705,7 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref)
if ( f->flags & tag->flags )
return 0;
if ( f->flags & IS_LABEL )
if ( is_flag_set(f->flags, IS_LABEL) )
___mkd_reparse(T(text), S(text), tag->flags, f, 0);
else if ( tag->link_pfx ) {
printlinkyref(f, tag, T(ref->link), S(ref->link));
......@@ -759,9 +769,9 @@ linkylinky(int image, MMIOT *f)
* require a second []
*/
mmiotseek(f, implicit_mark);
goodlink = !(f->flags & MKD_1_COMPAT);
goodlink = !is_flag_set(f->flags, MKD_1_COMPAT);
if ( (f->flags & MKD_EXTRA_FOOTNOTE) && (!image) && S(name) && T(name)[0] == '^' )
if ( is_flag_set(f->flags, MKD_EXTRA_FOOTNOTE) && (!image) && S(name) && T(name)[0] == '^' )
extra_footnote = 1;
}
......@@ -927,12 +937,12 @@ forbidden_tag(MMIOT *f)
{
int c = toupper(peek(f, 1));
if ( f->flags & MKD_NOHTML )
if ( is_flag_set(f->flags, MKD_NOHTML) )
return 1;
if ( c == 'A' && (f->flags & MKD_NOLINKS) && !isthisalnum(f,2) )
if ( c == 'A' && is_flag_set(f->flags, MKD_NOLINKS) && !isthisalnum(f,2) )
return 1;
if ( c == 'I' && (f->flags & MKD_NOIMAGE)
if ( c == 'I' && is_flag_set(f->flags, MKD_NOIMAGE)
&& strncasecmp(cursor(f)+1, "MG", 2) == 0
&& !isthisalnum(f,4) )
return 1;
......@@ -979,7 +989,7 @@ process_possible_link(MMIOT *f, int size)
int mailto = 0;
char *text = cursor(f);
if ( f->flags & MKD_NOLINKS ) return 0;
if ( is_flag_set(f->flags, MKD_NOLINKS) ) return 0;
if ( (size > 7) && strncasecmp(text, "mailto:", 7) == 0 ) {
/* if it says it's a mailto, it's a mailto -- who am
......@@ -1026,7 +1036,7 @@ maybe_tag_or_link(MMIOT *f)
int c, size;
int maybetag = 1;
if ( f->flags & MKD_TAGTEXT )
if ( is_flag_set(f->flags, MKD_TAGTEXT) )
return 0;
for ( size=0; (c = peek(f, size+1)) != '>'; size++) {
......@@ -1040,7 +1050,7 @@ maybe_tag_or_link(MMIOT *f)
else if ( isspace(c) )
break;
else if ( ! (c == '/'
|| (f->flags & MKD_GITHUBTAGS && (c == '-' || c == '_'))
|| (is_flag_set(f->flags, MKD_GITHUBTAGS) && (c == '-' || c == '_'))
|| isalnum(c) ) )
maybetag=0;
}
......@@ -1194,7 +1204,9 @@ smartypants(int c, int *flags, MMIOT *f)
{
int i;
if ( f->flags & (MKD_NOPANTS|MKD_TAGTEXT|IS_LABEL) )
if ( is_flag_set(f->flags, MKD_NOPANTS)
|| is_flag_set(f->flags, MKD_TAGTEXT)
|| is_flag_set(f->flags, IS_LABEL) )
return 0;
for ( i=0; i < NRSMART; i++)
......@@ -1286,7 +1298,7 @@ tickhandler(MMIOT *f, int tickchar, int minticks, int allow_space, spanhandler s
return 0;
}
#define tag_text(f) (f->flags & MKD_TAGTEXT)
#define tag_text(f) is_flag_set(f->flags, MKD_TAGTEXT)
static void
......@@ -1297,7 +1309,7 @@ text(MMIOT *f)
int smartyflags = 0;
while (1) {
if ( (f->flags & MKD_AUTOLINK) && isalpha(peek(f,1)) && !tag_text(f) )
if ( is_flag_set(f->flags, MKD_AUTOLINK) && isalpha(peek(f,1)) && !tag_text(f) )
maybe_autolink(f);
c = pull(f);
......@@ -1339,11 +1351,13 @@ text(MMIOT *f)
Qchar(c, f);
break;
/* A^B -> A<sup>B</sup> */
case '^': if ( (f->flags & (MKD_NOSUPERSCRIPT|MKD_STRICT|MKD_TAGTEXT))
|| (f->last == 0)
|| ((ispunct(f->last) || isspace(f->last))
&& f->last != ')')
|| isthisspace(f,1) )
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))
&& f->last != ')')
|| isthisspace(f,1) )
Qchar(c,f);
else {
char *sup = cursor(f);
......@@ -1376,9 +1390,8 @@ text(MMIOT *f)
break;
case '_':
/* Underscores don't count if they're in the middle of a word */
if ( !(f->flags & (MKD_NORELAXED|MKD_STRICT))
&& isthisalnum(f,-1)
&& isthisalnum(f,1) ) {
if ( !(is_flag_set(f->flags, MKD_NORELAXED) || is_flag_set(f->flags, MKD_STRICT))
&& isthisalnum(f,-1) && isthisalnum(f,1) ) {
Qchar(c, f);
break;
}
......@@ -1399,7 +1412,10 @@ text(MMIOT *f)
}
break;
case '~': if ( (f->flags & (MKD_NOSTRIKETHROUGH|MKD_TAGTEXT|MKD_STRICT)) || ! tickhandler(f,c,2,0, delspan) )
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);
break;
......@@ -1421,7 +1437,8 @@ text(MMIOT *f)
}
break;
case '^': if ( f->flags & (MKD_STRICT|MKD_NOSUPERSCRIPT) ) {
case '^': if ( is_flag_set(f->flags, MKD_STRICT)
|| is_flag_set(f->flags, MKD_NOSUPERSCRIPT) ) {
Qchar('\\', f);
shift(f,-1);
break;
......@@ -1430,7 +1447,7 @@ text(MMIOT *f)
break;
case ':': case '|':
if ( f->flags & MKD_NOTABLES ) {
if ( is_flag_set(f->flags, MKD_NOTABLES) ) {
Qchar('\\', f);
shift(f,-1);
break;
......@@ -1442,7 +1459,7 @@ text(MMIOT *f)
break;
case '[':
case '(': if ( (f->flags & MKD_LATEX)
case '(': if ( is_flag_set(f->flags, MKD_LATEX)