[Reproducible-commits] [discount] 38/121: Imported Upstream version 2.1.1.3
Jérémy Bobbio
lunar at moszumanska.debian.org
Tue Sep 23 20:56:15 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 38e6fbd298db50c9dce1aab2fbb2e5e4e3d25b8b
Author: Alessandro Ghedini <al3xbio at gmail.com>
Date: Mon Aug 1 22:23:13 2011 +0200
Imported Upstream version 2.1.1.3
---
Makefile.in | 5 ++
VERSION | 2 +-
configure.inc | 21 ++++-
configure.sh | 3 +
generate.c | 25 +++---
html5.c | 2 -
markdown.c | 228 +++++++++++++++++++++++++++++++++-----------------
markdown.h | 6 ++
tags.c => mktags.c | 66 ++++-----------
setup.c | 10 +--
tags.c | 100 ++++++++--------------
tests/code.t | 56 +++++++++++++
tests/dl.t | 13 +--
tests/functions.sh | 9 +-
tests/para.t | 6 +-
tests/peculiarities.t | 2 +-
tests/reddit.t | 2 +-
tests/smarty.t | 5 +-
tests/strikethrough.t | 1 +
tests/tables.t | 8 +-
version.c.in | 3 +
21 files changed, 332 insertions(+), 241 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 53ec5e2..18d6db3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -65,6 +65,11 @@ $(DESTDIR)/$(LIBDIR):
version.o: version.c VERSION
$(CC) -DVERSION=\"`cat VERSION`\" -c version.c
+tags.o: tags.c blocktags
+
+blocktags: mktags
+ ./mktags > blocktags
+
# example programs
@THEME at theme: theme.o $(MKDLIB) mkdio.h
@THEME@ $(CC) -o theme theme.o -lmarkdown @LIBS@
diff --git a/VERSION b/VERSION
index 7ec1d6d..8537c47 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.1.0
+2.1.1.3
diff --git a/configure.inc b/configure.inc
index 5115c86..3744678 100755
--- a/configure.inc
+++ b/configure.inc
@@ -826,9 +826,7 @@ EOF
# AC_C_VOLATILE checks to see if the compiler supports the volatile keyword
#
AC_C_VOLATILE () {
- cat > ngc$$.c << EOF
-f() { volatile char me=1; }
-EOF
+ echo 'f() { volatile char me=1; }' > ngc$$.c
LOGN "checking for \"volatile\" keyword"
if __MAKEDOTO ngc$$.c; then
@@ -843,6 +841,23 @@ EOF
#
+# AC_C_INLINE checks to see if compiler supports the inline keyword
+#
+AC_C_INLINE() {
+ echo 'inline int foo() { return 1; }' > ngc$$.c
+ LOGN 'Checking for "inline" keyword'
+ if __MAKEDOTO ngc$$.c; then
+ rc=0
+ else
+ AC_DEFINE inline '/**/'
+ rc=1
+ fi
+ __remove ngc$$.c
+ return $rc
+}
+
+
+#
# AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints.
#
AC_SCALAR_TYPES () {
diff --git a/configure.sh b/configure.sh
index b067865..43ef971 100755
--- a/configure.sh
+++ b/configure.sh
@@ -12,6 +12,7 @@ ac_help='--enable-amalloc Enable memory allocation debugging
--with-dl=X Use Discount, Extra, or Both types of definition list
--with-id-anchor Use id= anchors for table-of-contents links
--with-github-tags Allow `_` and `-` in <> tags
+--with-fenced-code Allow fenced code blocks
--enable-all-features Turn on all stable optional features
--shared Build shared libraries (default is static)'
@@ -53,6 +54,7 @@ BOTH) AC_DEFINE 'USE_EXTRA_DL' 1
*) AC_FAIL "Unknown value <$WITH_DL> for --with-dl (want 'discount', 'extra', or 'both')" ;;
esac
+test "$WITH_FENCED_CODE" && AC_DEFINE "WITH_FENCED_CODE" 1
test "$WITH_ID_ANCHOR" && AC_DEFINE 'WITH_ID_ANCHOR' 1
test "$WITH_GITHUB_TAGS" && AC_DEFINE 'WITH_GITHUB_TAGS' 1
@@ -70,6 +72,7 @@ AC_PROG ranlib
AC_C_VOLATILE
AC_C_CONST
+AC_C_INLINE
AC_SCALAR_TYPES sub hdr
AC_CHECK_BASENAME
diff --git a/generate.c b/generate.c
index 7f0f764..d9757e8 100644
--- a/generate.c
+++ b/generate.c
@@ -40,7 +40,7 @@ push(char *bfr, int size, MMIOT *f)
/* look <i> characters ahead of the cursor.
*/
-static int
+static inline int
peek(MMIOT *f, int i)
{
@@ -52,7 +52,7 @@ peek(MMIOT *f, int i)
/* pull a byte from the input buffer
*/
-static int
+static inline int
pull(MMIOT *f)
{
return ( f->isp < S(f->in) ) ? T(f->in)[f->isp++] : EOF;
@@ -61,14 +61,14 @@ pull(MMIOT *f)
/* return a pointer to the current position in the input buffer.
*/
-static char*
+static inline char*
cursor(MMIOT *f)
{
return T(f->in) + f->isp;
}
-static int
+static inline int
isthisspace(MMIOT *f, int i)
{
int c = peek(f, i);
@@ -77,7 +77,7 @@ isthisspace(MMIOT *f, int i)
}
-static int
+static inline int
isthisalnum(MMIOT *f, int i)
{
int c = peek(f, i);
@@ -86,7 +86,7 @@ isthisalnum(MMIOT *f, int i)
}
-static int
+static inline int
isthisnonword(MMIOT *f, int i)
{
return isthisspace(f, i) || ispunct(peek(f,i));
@@ -1093,8 +1093,8 @@ static struct smarties {
{ '\'', "'ve>", "rsquo", 0 },
{ '\'', "'m>", "rsquo", 0 },
{ '\'', "'d>", "rsquo", 0 },
- { '-', "--", "mdash", 1 },
- { '-', "<->", "ndash", 0 },
+ { '-', "---", "mdash", 2 },
+ { '-', "--", "ndash", 1 },
{ '.', "...", "hellip", 2 },
{ '.', ". . .", "hellip", 4 },
{ '(', "(c)", "copy", 2 },
@@ -1166,11 +1166,14 @@ smartypants(int c, int *flags, MMIOT *f)
* let the caller figure it out.
*/
static int
-tickhandler(MMIOT *f, int tickchar, int minticks, spanhandler spanner)
+tickhandler(MMIOT *f, int tickchar, int minticks, int allow_space, spanhandler spanner)
{
int endticks, size;
int tick = nrticks(0, tickchar, f);
+ if ( !allow_space && isspace(peek(f,tick)) )
+ return 0;
+
if ( (tick >= minticks) && (size = matchticks(f,tickchar,tick,&endticks)) ) {
if ( endticks < tick ) {
size += (tick - endticks);
@@ -1294,11 +1297,11 @@ text(MMIOT *f)
}
break;
- case '~': if ( (f->flags & (MKD_NOSTRIKETHROUGH|MKD_TAGTEXT|MKD_STRICT)) || !tickhandler(f,c,2,delspan) )
+ case '~': if ( (f->flags & (MKD_NOSTRIKETHROUGH|MKD_TAGTEXT|MKD_STRICT)) || ! tickhandler(f,c,2,0, delspan) )
Qchar(c, f);
break;
- case '`': if ( tag_text(f) || !tickhandler(f,c,1,codespan) )
+ case '`': if ( tag_text(f) || !tickhandler(f,c,1,1,codespan) )
Qchar(c, f);
break;
diff --git a/html5.c b/html5.c
index 8b86988..de91b90 100644
--- a/html5.c
+++ b/html5.c
@@ -10,8 +10,6 @@ mkd_with_html5_tags()
if ( populated ) return;
populated = 1;
- mkd_prepare_tags();
-
mkd_define_tag("ASIDE", 0);
mkd_define_tag("FOOTER", 0);
mkd_define_tag("HEADER", 0);
diff --git a/markdown.c b/markdown.c
index 4005b98..f4966c2 100644
--- a/markdown.c
+++ b/markdown.c
@@ -22,6 +22,9 @@ typedef int (*stfu)(const void*,const void*);
typedef ANCHOR(Paragraph) ParagraphRoot;
+static Paragraph *Pp(ParagraphRoot *, Line *, int);
+static Paragraph *compile(Line *, int, MMIOT *);
+
/* case insensitive string sort for Footnote tags.
*/
int
@@ -77,7 +80,7 @@ mkd_firstnonblank(Line *p)
}
-static int
+static inline int
blankline(Line *p)
{
return ! (p && (S(p->text) > p->dle) );
@@ -173,6 +176,61 @@ splitline(Line *t, int cutpoint)
}
}
+#define UNCHECK(l) ((l)->flags &= ~CHECKED)
+
+/*
+ * walk a line, seeing if it's any of half a dozen interesting regular
+ * types.
+ */
+static void
+checkline(Line *l)
+{
+ int eol, i;
+ int dashes = 0, spaces = 0,
+ equals = 0, underscores = 0,
+ stars = 0, tildes = 0;
+
+ l->flags |= CHECKED;
+ l->kind = chk_text;
+ l->count = 0;
+
+ if (l->dle >= 4) { l->kind=chk_code; return; }
+
+ for ( eol = S(l->text); eol > l->dle && isspace(T(l->text)[eol-1]); --eol )
+ ;
+
+ for (i=l->dle; i<eol; i++) {
+ register int c = T(l->text)[i];
+
+ if ( c != ' ' ) l->count++;
+
+ switch (c) {
+ case '-': dashes = 1; break;
+ case ' ': spaces = 1; break;
+ case '=': equals = 1; break;
+ case '_': underscores = 1; break;
+ case '*': stars = 1; break;
+ case '~': tildes = 1; break;
+ default: return;
+ }
+ }
+
+ if ( dashes + equals + underscores + stars + tildes > 1 )
+ return;
+
+ if ( spaces ) {
+ if ( (underscores || stars || dashes) )
+ l->kind = chk_hr;
+ return;
+ }
+
+ if ( stars || underscores ) { l->kind = chk_hr; }
+ else if ( dashes ) { l->kind = chk_dash; }
+ else if ( tildes ) { l->kind = chk_tilde; }
+ else if ( equals ) { l->kind = chk_equal; }
+}
+
+
static Line *
commentblock(Paragraph *p, int *unclosed)
@@ -322,76 +380,46 @@ isfootnote(Line *t)
}
-static int
+static inline int
isquote(Line *t)
{
- int j;
-
- for ( j=0; j < 4; j++ )
- if ( T(t->text)[j] == '>' )
- return 1;
- else if ( !isspace(T(t->text)[j]) )
- return 0;
- return 0;
-}
-
-
-static int
-dashchar(char c)
-{
- return (c == '*') || (c == '-') || (c == '_');
+ return (t->dle < 4 && T(t->text)[t->dle] == '>');
}
-static int
+static inline int
iscode(Line *t)
{
return (t->dle >= 4);
}
-static int
+static inline int
ishr(Line *t)
{
- int i, count=0;
- char dash = 0;
- char c;
+ if ( ! (t->flags & CHECKED) )
+ checkline(t);
- if ( iscode(t) ) return 0;
-
- for ( i = 0; i < S(t->text); i++) {
- c = T(t->text)[i];
- if ( (dash == 0) && dashchar(c) )
- dash = c;
-
- if ( c == dash ) ++count;
- else if ( !isspace(c) )
- return 0;
- }
- return (count >= 3);
+ if ( t->count > 2 )
+ return t->kind == chk_hr || t->kind == chk_dash || t->kind == chk_equal;
+ return 0;
}
static int
issetext(Line *t, int *htyp)
{
- int i;
- /* then check for setext-style HEADER
- * ======
+ Line *n;
+
+ /* check for setext-style HEADER
+ * ======
*/
- if ( t->next ) {
- char *q = T(t->next->text);
- int last = S(t->next->text);
-
- if ( (*q == '=') || (*q == '-') ) {
- /* ignore trailing whitespace */
- while ( (last > 1) && isspace(q[last-1]) )
- --last;
+ if ( (n = t->next) ) {
+ if ( !(n->flags & CHECKED) )
+ checkline(n);
- for (i=1; i < last; i++)
- if ( q[0] != q[i] )
- return 0;
+ if ( n->kind == chk_dash || n->kind == chk_equal ) {
*htyp = SETEXT;
return 1;
}
@@ -403,28 +431,31 @@ issetext(Line *t, int *htyp)
static int
ishdr(Line *t, int *htyp)
{
- int i;
-
-
- /* first check for etx-style ###HEADER###
- */
-
- /* leading run of `#`'s ?
- */
- for ( i=0; T(t->text)[i] == '#'; ++i)
- ;
-
/* ANY leading `#`'s make this into an ETX header
*/
- if ( i && (i < S(t->text) || i > 1) ) {
+ if ( (t->dle == 0) && (S(t->text) > 1) && (T(t->text)[0] == '#') ) {
*htyp = ETX;
return 1;
}
+ /* And if not, maybe it's a SETEXT header instead
+ */
return issetext(t, htyp);
}
+static inline int
+end_of_block(Line *t)
+{
+ int dummy;
+
+ if ( !t )
+ return 0;
+
+ return ( (S(t->text) <= t->dle) || ishr(t) || ishdr(t, &dummy) );
+}
+
+
static Line*
is_discount_dt(Line *t, int *clip)
{
@@ -458,13 +489,12 @@ static Line*
is_extra_dt(Line *t, int *clip)
{
#if USE_EXTRA_DL
- int i;
if ( t && t->next && T(t->text)[0] != '='
&& T(t->text)[S(t->text)-1] != '=') {
Line *x;
- if ( iscode(t) || blankline(t) || ishdr(t,&i) || ishr(t) )
+ if ( iscode(t) || end_of_block(t) )
return 0;
if ( (x = skipempty(t->next)) && is_extra_dd(x) ) {
@@ -500,7 +530,7 @@ islist(Line *t, int *clip, DWORD flags, int *list_type)
int i, j;
char *q;
- if ( /*iscode(t) ||*/ blankline(t) || ishdr(t,&i) || ishr(t) )
+ if ( end_of_block(t) )
return 0;
if ( !(flags & (MKD_NODLIST|MKD_STRICT)) && isdefinition(t,clip,list_type) )
@@ -571,6 +601,7 @@ headerblock(Paragraph *pp, int htyp)
++i;
CLIP(p->text, 0, i);
+ UNCHECK(p);
for (j=S(p->text); (j > 1) && (T(p->text)[j-1] == '#'); --j)
;
@@ -607,6 +638,46 @@ codeblock(Paragraph *p)
}
+#ifdef WITH_FENCED_CODE
+static int
+iscodefence(Line *r, int size)
+{
+ if ( !(r->flags & CHECKED) )
+ checkline(r);
+
+ return (r->kind == chk_tilde) && (r->count >= size);
+}
+
+static Paragraph *
+fencedcodeblock(ParagraphRoot *d, Line **ptr)
+{
+ Line *first, *r;
+ Paragraph *ret;
+
+ first = (*ptr);
+
+ /* don't allow zero-length code fences
+ */
+ if ( (first->next == 0) || iscodefence(first->next, first->count) )
+ 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) ) {
+ (*ptr) = r->next->next;
+ ret = Pp(d, first->next, CODE);
+ ___mkd_freeLine(first);
+ ___mkd_freeLine(r->next);
+ r->next = 0;
+ return ret;
+ }
+ return 0;
+}
+#endif
+
+
static int
centered(Line *first, Line *last)
{
@@ -630,19 +701,18 @@ endoftextblock(Line *t, int toplevelblock, DWORD flags)
{
int z;
- if ( blankline(t)||isquote(t)||ishdr(t,&z)||ishr(t) )
+ if ( end_of_block(t) || isquote(t) )
return 1;
- /* HORRIBLE STANDARDS KLUDGE: non-toplevel paragraphs absorb adjacent
- * code blocks
+ /* HORRIBLE STANDARDS KLUDGES:
+ * 1. non-toplevel paragraphs absorb adjacent code blocks
+ * 2. Toplevel paragraphs eat absorb adjacent list items,
+ * but sublevel blocks behave properly.
+ * (What this means is that we only need to check for code
+ * blocks at toplevel, and only check for list items at
+ * nested levels.)
*/
- if ( toplevelblock && iscode(t) )
- return 1;
-
- /* HORRIBLE STANDARDS KLUDGE: Toplevel paragraphs eat absorb adjacent
- * list items, but sublevel blocks behave properly.
- */
- return toplevelblock ? 0 : islist(t,&z,flags, &z);
+ return toplevelblock ? 0 : islist(t,&z,flags,&z);
}
@@ -713,7 +783,7 @@ isdivmarker(Line *p, int start, DWORD flags)
*
* one sick horrible thing about blockquotes is that even though
* it just takes ^> to start a quote, following lines, if quoted,
- * assume that the prefix is ``>''. This means that code needs
+ * assume that the prefix is ``> ''. This means that code needs
* to be indented *5* spaces from the leading '>', but *4* spaces
* from the start of the line. This does not appear to be
* documented in the reference implementation, but it's the
@@ -738,6 +808,7 @@ quoteblock(Paragraph *p, DWORD flags)
if ( T(t->text)[qp] == ' ' )
qp++;
CLIP(t->text, 0, qp);
+ UNCHECK(t);
t->dle = mkd_firstnonblank(t);
}
@@ -789,9 +860,6 @@ tableblock(Paragraph *p)
}
-static Paragraph *Pp(ParagraphRoot *, Line *, int);
-static Paragraph *compile(Line *, int, MMIOT *);
-
typedef int (*linefn)(Line *);
@@ -810,6 +878,7 @@ listitem(Paragraph *p, int indent, DWORD flags, linefn check)
for ( t = p->text; t ; t = q) {
CLIP(t->text, 0, clip);
+ UNCHECK(t);
t->dle = mkd_firstnonblank(t);
if ( (q = skipempty(t->next)) == 0 ) {
@@ -870,6 +939,7 @@ definition_block(Paragraph *top, int clip, MMIOT *f, int kind)
if ( kind == 1 /* discount dl */ )
for ( q = labels; q; q = q->next ) {
CLIP(q->text, 0, 1);
+ UNCHECK(q);
S(q->text)--;
}
@@ -1149,6 +1219,10 @@ compile(Line *ptr, int toplevel, MMIOT *f)
ptr = codeblock(p);
}
+#if WITH_FENCED_CODE
+ else if ( iscodefence(ptr,3) && (p=fencedcodeblock(&d, &ptr)) )
+ /* yay, it's already done */ ;
+#endif
else if ( ishr(ptr) ) {
p = Pp(&d, 0, HR);
r = ptr;
diff --git a/markdown.h b/markdown.h
index f6b05fc..4c7d181 100644
--- a/markdown.h
+++ b/markdown.h
@@ -29,6 +29,12 @@ typedef struct line {
int dle; /* leading indent on the line */
int flags; /* special attributes for this line */
#define PIPECHAR 0x01 /* line contains a | */
+#define CHECKED 0x02
+
+ enum { chk_text, chk_code,
+ chk_hr, chk_dash,
+ chk_tilde, chk_equal } kind;
+ int count;
} Line;
diff --git a/tags.c b/mktags.c
similarity index 62%
copy from tags.c
copy to mktags.c
index 00affc1..728a649 100644
--- a/tags.c
+++ b/mktags.c
@@ -1,5 +1,7 @@
/* block-level tags for passing html blocks through the blender
*/
+#include <stdio.h>
+
#define __WITHOUT_AMALLOC 1
#include "cstring.h"
#include "tags.h"
@@ -9,8 +11,8 @@ STRING(struct kw) blocktags;
/* define a html block tag
*/
-void
-mkd_define_tag(char *id, int selfclose)
+static void
+define_one_tag(char *id, int selfclose)
{
struct kw *p = &EXPAND(blocktags);
@@ -37,45 +39,16 @@ casort(struct kw *a, struct kw *b)
typedef int (*stfu)(const void*,const void*);
-/* sort the list of html block tags for later searching
- */
-void
-mkd_sort_tags()
-{
- qsort(T(blocktags), S(blocktags), sizeof(struct kw), (stfu)casort);
-}
-
-
-
-/* look for a token in the html block tag list
- */
-struct kw*
-mkd_search_tags(char *pat, int len)
-{
- struct kw key;
-
- key.id = pat;
- key.size = len;
-
- return bsearch(&key, T(blocktags), S(blocktags), sizeof key, (stfu)casort);
-}
-
-
-static int populated = 0;
-
-
/* load in the standard collection of html tags that markdown supports
*/
-void
-mkd_prepare_tags()
+int
+main()
{
+ int i;
-#define KW(x) mkd_define_tag(x, 0)
-#define SC(x) mkd_define_tag(x, 1)
+#define KW(x) define_one_tag(x, 0)
+#define SC(x) define_one_tag(x, 1)
- if ( populated ) return;
- populated = 1;
-
KW("STYLE");
KW("SCRIPT");
KW("ADDRESS");
@@ -107,17 +80,12 @@ mkd_prepare_tags()
KW("IFRAME");
KW("MAP");
- mkd_sort_tags();
-} /* mkd_prepare_tags */
-
+ qsort(T(blocktags), S(blocktags), sizeof(struct kw), (stfu)casort);
-/* destroy the blocktags list (for shared libraries)
- */
-void
-mkd_deallocate_tags()
-{
- if ( S(blocktags) > 0 ) {
- populated = 0;
- DELETE(blocktags);
- }
-} /* mkd_deallocate_tags */
+ printf("static struct kw blocktags[] = {\n");
+ for (i=0; i < S(blocktags); i++)
+ printf(" { \"%s\", %d, %d },\n", T(blocktags)[i].id, T(blocktags)[i].size, T(blocktags)[i].selfclose );
+ printf("};\n\n");
+ printf("#define NR_blocktags %d\n", S(blocktags));
+ exit(0);
+}
diff --git a/setup.c b/setup.c
index 79f47aa..988a6aa 100644
--- a/setup.c
+++ b/setup.c
@@ -18,7 +18,6 @@
#include "amalloc.h"
#include "tags.h"
-static int need_to_setup = 1;
static int need_to_initrng = 1;
void
@@ -29,19 +28,12 @@ mkd_initialize()
need_to_initrng = 0;
INITRNG(time(0));
}
- if ( need_to_setup ) {
- need_to_setup = 0;
- mkd_prepare_tags();
- }
}
void
mkd_shlib_destructor()
{
- if ( !need_to_setup ) {
- need_to_setup = 1;
- mkd_deallocate_tags();
- }
+ mkd_deallocate_tags();
}
diff --git a/tags.c b/tags.c
index 00affc1..b5043dd 100644
--- a/tags.c
+++ b/tags.c
@@ -4,19 +4,33 @@
#include "cstring.h"
#include "tags.h"
-STRING(struct kw) blocktags;
+STRING(struct kw) extratags;
+
+/* the standard collection of tags are built and sorted when
+ * discount is configured, so all we need to do is pull them
+ * in and use them.
+ *
+ * Additional tags still need to be allocated, sorted, and deallocated.
+ */
+#include "blocktags"
-/* define a html block tag
+/* define an additional html block tag
*/
void
mkd_define_tag(char *id, int selfclose)
{
- struct kw *p = &EXPAND(blocktags);
-
- p->id = id;
- p->size = strlen(id);
- p->selfclose = selfclose;
+ struct kw *p;
+
+ /* only add the new tag if it doesn't exist in
+ * either the standard or extra tag tables.
+ */
+ if ( !(p = mkd_search_tags(id, strlen(id))) ) {
+ p = &EXPAND(extratags);
+ p->id = id;
+ p->size = strlen(id);
+ p->selfclose = selfclose;
+ }
}
@@ -37,87 +51,41 @@ casort(struct kw *a, struct kw *b)
typedef int (*stfu)(const void*,const void*);
-/* sort the list of html block tags for later searching
+/* sort the list of extra html block tags for later searching
*/
void
mkd_sort_tags()
{
- qsort(T(blocktags), S(blocktags), sizeof(struct kw), (stfu)casort);
+ qsort(T(extratags), S(extratags), sizeof(struct kw), (stfu)casort);
}
-
/* look for a token in the html block tag list
*/
struct kw*
mkd_search_tags(char *pat, int len)
{
struct kw key;
+ struct kw *ret;
key.id = pat;
key.size = len;
- return bsearch(&key, T(blocktags), S(blocktags), sizeof key, (stfu)casort);
-}
-
-
-static int populated = 0;
+ if ( (ret=bsearch(&key,blocktags,NR_blocktags,sizeof key,(stfu)casort)) )
+ return ret;
+ if ( S(extratags) )
+ return bsearch(&key,T(extratags),S(extratags),sizeof key,(stfu)casort);
+
+ return 0;
+}
-/* load in the standard collection of html tags that markdown supports
- */
-void
-mkd_prepare_tags()
-{
-
-#define KW(x) mkd_define_tag(x, 0)
-#define SC(x) mkd_define_tag(x, 1)
- if ( populated ) return;
- populated = 1;
-
- KW("STYLE");
- KW("SCRIPT");
- KW("ADDRESS");
- KW("BDO");
- KW("BLOCKQUOTE");
- KW("CENTER");
- KW("DFN");
- KW("DIV");
- KW("OBJECT");
- KW("H1");
- KW("H2");
- KW("H3");
- KW("H4");
- KW("H5");
- KW("H6");
- KW("LISTING");
- KW("NOBR");
- KW("UL");
- KW("P");
- KW("OL");
- KW("DL");
- KW("PLAINTEXT");
- KW("PRE");
- KW("TABLE");
- KW("WBR");
- KW("XMP");
- SC("HR");
- SC("BR");
- KW("IFRAME");
- KW("MAP");
-
- mkd_sort_tags();
-} /* mkd_prepare_tags */
-
-
-/* destroy the blocktags list (for shared libraries)
+/* destroy the extratags list (for shared libraries)
*/
void
mkd_deallocate_tags()
{
- if ( S(blocktags) > 0 ) {
- populated = 0;
- DELETE(blocktags);
- }
+ if ( S(extratags) > 0 )
+ DELETE(extratags);
} /* mkd_deallocate_tags */
diff --git a/tests/code.t b/tests/code.t
index 8e8f20c..92df860 100644
--- a/tests/code.t
+++ b/tests/code.t
@@ -31,5 +31,61 @@ try 'backslashes in code(1)' ' printf "%s: \n", $1;' \
try 'backslashes in code(2)' '`printf "%s: \n", $1;`' \
'<p><code>printf "%s: \n", $1;</code></p>'
+if ./markdown -V | grep FENCED-CODE >/dev/null; then
+
+try 'fenced code block' \
+'~~~
+code!
+~~~' \
+ '<pre><code>code!
+</code></pre>'
+
+try 'fenced code block in list' \
+'1. ~~~
+code block
+~~~' \
+'<ol>
+<li><pre><code>code block
+</code></pre></li>
+</ol>'
+
+try 'fenced code block in blockquote' \
+'>~~~
+code
+~~~' \
+'<blockquote><pre><code>code
+</code></pre></blockquote>'
+
+try 'unterminated fenced code block' \
+'~~~
+code' \
+'<p>~~~
+code</p>'
+
+try 'fenced code block with tildes' \
+'~~~~~
+~~~
+code with tildes
+~~~
+~~~~~' \
+'<pre><code>~~~
+code with tildes
+~~~
+</code></pre>'
+
+try 'paragraph with trailing fenced block' \
+'text text text
+text text text
+~~~
+code code code?
+~~~' \
+'<p>text text text
+text text text
+~~~
+code code code?
+~~~</p>'
+
+fi
+
summary $0
exit $rc
diff --git a/tests/dl.t b/tests/dl.t
index 99d1fe4..5465a81 100644
--- a/tests/dl.t
+++ b/tests/dl.t
@@ -37,15 +37,10 @@ if [ "$DL" = "DISCOUNT" -o "$DL" = "BOTH" ]; then
try -fnodefinitionlist '=tag= does nothing' "$SRC" \
- '<p>=this=</p>
-
-<pre><code>is an ugly
-</code></pre>
-
-<p>=test=</p>
-
-<pre><code>eh?
-</code></pre>'
+ '<p>=this=
+ is an ugly
+=test=
+ eh?</p>'
fi
if [ "$DL" = "EXTRA" -o "$DL" = "BOTH" ]; then
diff --git a/tests/functions.sh b/tests/functions.sh
index ae0b2a3..3ca8656 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -57,8 +57,13 @@ try() {
./echo
./echo "$1"
fi
- ./echo "wanted: $3"
- ./echo "got : $Q"
+ ./echo "source:"
+ ./echo "$2" | sed -e 's/^/ /'
+ ./echo "diff:"
+ (./echo "$3" >> $$.w
+ ./echo "$Q" >> $$.g
+ diff $$.w $$.g ) | sed -e 's/^/ /'
+ rm -f $$.w $$.g
rc=1
fi
}
diff --git a/tests/para.t b/tests/para.t
index 29445e5..74a6598 100644
--- a/tests/para.t
+++ b/tests/para.t
@@ -8,10 +8,8 @@ MARKDOWN_FLAGS=
try 'paragraph followed by code' \
'a
b' \
- '<p>a</p>
-
-<pre><code>b
-</code></pre>'
+ '<p>a
+ b</p>'
try 'single-line paragraph' 'a' '<p>a</p>'
diff --git a/tests/peculiarities.t b/tests/peculiarities.t
index f97597f..77d41dc 100644
--- a/tests/peculiarities.t
+++ b/tests/peculiarities.t
@@ -13,7 +13,7 @@ try 'list followed by header .......... ' \
'<ul>
<li>AAA
-<h2>– BBB</h2></li>
+<h2>- BBB</h2></li>
</ul>'
try 'ul with mixed item prefixes' \
diff --git a/tests/reddit.t b/tests/reddit.t
index 268cbcf..3215edc 100644
--- a/tests/reddit.t
+++ b/tests/reddit.t
@@ -6,7 +6,7 @@ rc=0
MARKDOWN_FLAGS=
try 'smiley faces?' '[8-9] <]:-( x ---> [4]' \
- '<p>[8-9] <]:–( x —–> [4]</p>'
+ '<p>[8-9] <]:-( x —> [4]</p>'
try 'really long ETX headers' \
'#####################################################hi' \
diff --git a/tests/smarty.t b/tests/smarty.t
index 8c9ccc5..0ce2ee4 100644
--- a/tests/smarty.t
+++ b/tests/smarty.t
@@ -10,9 +10,10 @@ try '(r) -> ®' '(r)' '<p>®</p>'
try '(tm) -> ™' '(tm)' '<p>™</p>'
try '... -> …' '...' '<p>…</p>'
-try '"--" -> —' '--' '<p>—</p>'
+try '"?--" -> –' '?--' '<p>?–</p>'
+try '"?---" -> —' '?---' '<p>?—</p>'
-try '"-" -> –' 'regular -' '<p>regular –</p>'
+try '"--" -> –' 'regular --' '<p>regular –</p>'
try 'A-B -> A-B' 'A-B' '<p>A-B</p>'
try '"fancy" -> “fancy”' '"fancy"' '<p>“fancy”</p>'
try "'fancy'" "'fancy'" '<p>‘fancy’</p>'
diff --git a/tests/strikethrough.t b/tests/strikethrough.t
index 9016a5c..ffb0c50 100644
--- a/tests/strikethrough.t
+++ b/tests/strikethrough.t
@@ -10,6 +10,7 @@ try -fnodel '... with -fnodel' '~~deleted~~' '<p>~~deleted~~</p>'
try 'mismatched tildes' '~~~tick~~' '<p><del>~tick</del></p>'
try 'mismatched tildes(2)' '~~tick~~~' '<p>~~tick~~~</p>'
try 'single tildes' '~tick~' '<p>~tick~</p>'
+try 'tildes wrapped in spaces' '~~~ ~~~' '<p>~~~ ~~~</p>'
summary $0
exit $rc
diff --git a/tests/tables.t b/tests/tables.t
index 97e55ea..50f2933 100644
--- a/tests/tables.t
+++ b/tests/tables.t
@@ -137,7 +137,7 @@ try -fnotables 'tables with -fnotables' \
-|-
hello|sailor' \
'<p>a|b
-–|–
+-|-
hello|sailor</p>'
try 'deceptive non-table text' \
@@ -152,7 +152,7 @@ try 'table headers only' \
'a|b|c
-|-|-' \
'<p>a|b|c
-–|–|–</p>'
+-|-|-</p>'
try 'escaped title line' \
'A\|B
@@ -177,7 +177,7 @@ try 'escaped dashes line' \
-\|-
C |D' \
'<p>A |B
-–|–
+-|-
C |D</p>'
try 'escaped content line' \
@@ -204,7 +204,7 @@ try 'content line w/o dashes' \
--|-
CD' \
'<p>A |B
-—|–
+–|-
CD</p>'
summary $0
diff --git a/version.c.in b/version.c.in
index 07ec94d..aaa0722 100644
--- a/version.c.in
+++ b/version.c.in
@@ -24,4 +24,7 @@ char markdown_version[] = VERSION
#if WITH_GITHUB_TAGS
" GITHUB-TAGS"
#endif
+#if WITH_FENCED_CODE
+ " FENCED-CODE"
+#endif
;
--
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