[Reproducible-commits] [discount] 11/121: Imported Upstream version 2.0.6

Jérémy Bobbio lunar at moszumanska.debian.org
Tue Sep 23 20:56:12 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 faa4de332fcc62e7709c5ae330403c51183a3300
Author: Alessandro Ghedini <al3xbio at gmail.com>
Date:   Sat Feb 19 18:11:26 2011 +0100

    Imported Upstream version 2.0.6
---
 VERSION                |  2 +-
 dumptree.c             |  2 +-
 flags.c                |  1 +
 generate.c             | 67 +++++++++++++++++++++++++++++++++++++++++++++++---
 main.c                 |  8 +++---
 markdown.c             |  7 ++++++
 markdown.h             | 10 +++++++-
 mkdio.c                |  2 +-
 mkdio.h.in             |  8 +++++-
 tests/extrafootnotes.t | 25 +++++++++++++++++++
 toc.c                  |  6 +++--
 11 files changed, 125 insertions(+), 13 deletions(-)

diff --git a/VERSION b/VERSION
index e010258..157e54f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.0.5
+2.0.6
diff --git a/dumptree.c b/dumptree.c
index 0680848..0c0c01f 100644
--- a/dumptree.c
+++ b/dumptree.c
@@ -111,7 +111,7 @@ dumptree(Paragraph *pp, Stack *sp, FILE *f)
 	d = fprintf(f, "[%s", Pptype(pp->typ));
 	if ( pp->ident )
 	    d += fprintf(f, " %s", pp->ident);
-	if ( pp->align )
+	if ( pp->align > 1 )
 	    d += fprintf(f, ", <%s>", Begin[pp->align]);
 
 	for (count=0, p=pp->text; p; ++count, (p = p->next) )
diff --git a/flags.c b/flags.c
index 4021a8b..5bf206c 100644
--- a/flags.c
+++ b/flags.c
@@ -28,6 +28,7 @@ static struct flagnames flagnames[] = {
     { MKD_NODIVQUOTE,     "!DIVQUOTE" },
     { MKD_NOALPHALIST,    "!ALPHALIST" },
     { MKD_NODLIST,        "!DLIST" },
+    { MKD_EXTRA_FOOTNOTE, "FOOTNOTE" },
 };
 #define NR(x)	(sizeof x/sizeof x[0])
 
diff --git a/generate.c b/generate.c
index 4f665fc..1c18bc6 100644
--- a/generate.c
+++ b/generate.c
@@ -564,6 +564,26 @@ printlinkyref(MMIOT *f, linkytype *tag, char *link, int size)
 } /* printlinkyref */
 
 
+/* php markdown extra/daring fireball style print footnotes
+ */
+static int
+extra_linky(MMIOT *f, Cstring text, Footnote *ref)
+{
+    if ( ref->flags & REFERENCED )
+	return 0;
+	
+    if ( f->flags & IS_LABEL )
+    	___mkd_reparse(T(text), S(text), linkt.flags, f);
+    else {
+	ref->flags |= REFERENCED;
+	ref->refnumber = ++ f->reference;
+	Qprintf(f, "<sup id=\"fnref:%d\"><a href=\"#fn:%d\" rel=\"footnote\">%d</a></sup>",
+		ref->refnumber, ref->refnumber, ref->refnumber);
+    }
+    return 1;
+} /* extra_linky */
+
+
 /* print out a linky (or fail if it's Not Allowed)
  */
 static int
@@ -628,6 +648,7 @@ linkylinky(int image, MMIOT *f)
     Footnote key, *ref;
 		
     int status = 0;
+    int extra_footnote = 0;
 
     CREATE(name);
     memset(&key, 0, sizeof key);
@@ -654,6 +675,9 @@ linkylinky(int image, MMIOT *f)
 		 */
 		mmiotseek(f, implicit_mark);
 		goodlink = !(f->flags & MKD_1_COMPAT);
+
+		if ( (f->flags & MKD_EXTRA_FOOTNOTE) && (!image) && S(name) && T(name)[0] == '^' )
+		    extra_footnote = 1;
 	    }
 	    
 	    if ( goodlink ) {
@@ -664,8 +688,12 @@ linkylinky(int image, MMIOT *f)
 		}
 
 		if ( ref = bsearch(&key, T(*f->footnotes), S(*f->footnotes),
-					  sizeof key, (stfu)__mkd_footsort) )
-		    status = linkyformat(f, name, image, ref);
+					  sizeof key, (stfu)__mkd_footsort) ) {
+		    if ( extra_footnote )
+			status = extra_linky(f,name,ref);
+		    else
+			status = linkyformat(f, name, image, ref);
+		}
 		else if ( f->flags & IS_LABEL )
 		    status = linkyformat(f, name, image, 0);
 	    }
@@ -1314,7 +1342,9 @@ printheader(Paragraph *pp, MMIOT *f)
 {
     if ( f->flags & MKD_TOC ) {
 	Qstring("<a name=\"", f);
-	mkd_string_to_anchor(T(pp->text->text), S(pp->text->text), Qchar, f, 1);
+	mkd_string_to_anchor(T(pp->text->text),
+			     S(pp->text->text),
+			     (mkd_sta_function_t)Qchar, f, 1);
 	Qstring("\"></a>\n", f);
     }
     Qprintf(f, "<h%d>", pp->hnumber);
@@ -1615,6 +1645,35 @@ display(Paragraph *p, MMIOT *f)
 }
 
 
+/* dump out a list of footnotes
+ */
+static void
+mkd_extra_footnotes(MMIOT *m)
+{
+    int j, i;
+    Footnote *t;
+
+    if ( m->reference == 0 )
+	return;
+
+    Csprintf(&m->out, "\n<div class=\"footnotes\">\n<hr/>\n<ol>\n");
+    
+    for ( i=1; i <= m->reference; i++ ) {
+	for ( j=0; j < S(*m->footnotes); j++ ) {
+	    t = &T(*m->footnotes)[j];
+	    if ( (t->refnumber == i) && (t->flags & REFERENCED) ) {
+		Csprintf(&m->out, "<li id=\"fn:%d\">\n<p>", t->refnumber);
+		Csreparse(&m->out, T(t->title), S(t->title), 0);
+		Csprintf(&m->out, "<a href=\"#fnref:%d\" rev=\"footnote\">↩</a>",
+			    t->refnumber);
+		Csprintf(&m->out, "</p></li>\n");
+	    }
+	}
+    }
+    Csprintf(&m->out, "</ol>\n</div>\n");
+}
+
+
 /* return a pointer to the compiled markdown
  * document.
  */
@@ -1626,6 +1685,8 @@ mkd_document(Document *p, char **res)
     if ( p && p->compiled ) {
 	if ( ! p->html ) {
 	    htmlify(p->code, 0, 0, p->ctx);
+	    if ( p->ctx->flags & MKD_EXTRA_FOOTNOTE )
+		mkd_extra_footnotes(p->ctx);
 	    p->html = 1;
 	}
 
diff --git a/main.c b/main.c
index 736dc1f..049515c 100644
--- a/main.c
+++ b/main.c
@@ -39,7 +39,7 @@ char *pgm = "markdown";
 static struct {
     char *name;
     int off;
-    int flag;
+    mkd_flag_t flag;
 } opts[] = {
     { "tabstop",       0, MKD_TABSTOP  },
     { "image",         1, MKD_NOIMAGE  },
@@ -64,13 +64,15 @@ static struct {
     { "alphalist",     1, MKD_NOALPHALIST },
     { "definitionlist",1, MKD_NODLIST },
     { "1.0",           0, MKD_1_COMPAT },
+    { "footnotes",     0, MKD_EXTRA_FOOTNOTE },
+    { "footnote",      0, MKD_EXTRA_FOOTNOTE },
 } ;
 
 #define NR(x)	(sizeof x / sizeof x[0])
     
 
 void
-set(int *flags, char *optionstring)
+set(mkd_flag_t *flags, char *optionstring)
 {
     int i;
     int enable;
@@ -117,7 +119,7 @@ main(int argc, char **argv)
 {
     int opt;
     int rc;
-    int flags = 0;
+    mkd_flag_t flags = 0;
     int debug = 0;
     int toc = 0;
     int version = 0;
diff --git a/markdown.c b/markdown.c
index 8510b70..3a7acff 100644
--- a/markdown.c
+++ b/markdown.c
@@ -966,6 +966,12 @@ addfootnote(Line *p, MMIOT* f)
     S(foot->tag)--;
     j = nextnonblank(p, j+2);
 
+    if ( (f->flags & MKD_EXTRA_FOOTNOTE) && (T(foot->tag)[0] == '^') ) {
+	while ( j < S(p->text) )
+	    EXPAND(foot->title) = T(p->text)[j++];
+	goto skip_to_end;
+    }
+
     while ( (j < S(p->text)) && !isspace(T(p->text)[j]) )
 	EXPAND(foot->link) = T(p->text)[j++];
     EXPAND(foot->link) = 0;
@@ -1005,6 +1011,7 @@ addfootnote(Line *p, MMIOT* f)
 	--S(foot->title);
     }
 
+skip_to_end:
     ___mkd_freeLine(p);
     return np;
 }
diff --git a/markdown.h b/markdown.h
index 5a6d705..7e3ca0b 100644
--- a/markdown.h
+++ b/markdown.h
@@ -12,6 +12,10 @@ typedef struct footnote {
     Cstring title;		/* what it's called (TITLE= attribute) */
     int height, width;		/* dimensions (for image link) */
     int dealloc;		/* deallocation needed? */
+    int refnumber;
+    int flags;
+#define EXTRA_BOOKMARK	0x01
+#define REFERENCED	0x02
 } Footnote;
 
 /* each input line is read into a Line, which contains the line,
@@ -75,6 +79,7 @@ typedef struct mmiot {
     Cstring in;
     Qblock Q;
     int isp;
+    int reference;
     STRING(Footnote) *footnotes;
     DWORD flags;
 #define MKD_NOLINKS	0x00000001
@@ -98,6 +103,7 @@ typedef struct mmiot {
 #define MKD_NODIVQUOTE	0x00040000
 #define MKD_NOALPHALIST	0x00080000
 #define MKD_NODLIST	0x00100000
+#define MKD_EXTRA_FOOTNOTE 0x00200000
 #define IS_LABEL	0x08000000
 #define USER_FLAGS	0x0FFFFFFF
 #define INPUT_MASK	(MKD_NOHEADER|MKD_TABSTOP)
@@ -143,7 +149,9 @@ extern int  mkd_line(char *, int, char **, DWORD);
 extern int  mkd_generateline(char *, int, FILE*, DWORD);
 #define mkd_text mkd_generateline
 extern void mkd_basename(Document*, char *);
-extern void mkd_string_to_anchor(char*,int, void(*)(int,void*), void*, int);
+
+typedef int (*mkd_sta_function_t)(const int,const void*);
+extern void mkd_string_to_anchor(char*,int, mkd_sta_function_t, void*, int);
 
 extern Document *mkd_in(FILE *, DWORD);
 extern Document *mkd_string(char*,int, DWORD);
diff --git a/mkdio.c b/mkdio.c
index 13784fd..0af514e 100644
--- a/mkdio.c
+++ b/mkdio.c
@@ -215,7 +215,7 @@ markdown(Document *document, FILE *out, int flags)
 /* write out a Cstring, mangled into a form suitable for `<a href=` or `<a id=`
  */
 void
-mkd_string_to_anchor(char *s, int len, void(*outchar)(int,void*),
+mkd_string_to_anchor(char *s, int len, mkd_sta_function_t outchar,
 				       void *out, int labelformat)
 {
     unsigned char c;
diff --git a/mkdio.h.in b/mkdio.h.in
index 7ab658c..5cf6696 100644
--- a/mkdio.h.in
+++ b/mkdio.h.in
@@ -15,6 +15,7 @@ MMIOT *mkd_string(char*,int,mkd_flag_t);	/* assemble input from a buffer */
 void mkd_basename(MMIOT*,char*);
 
 void mkd_initialize();
+void mkd_with_html5_tags();
 void mkd_shlib_destructor();
 
 /* compilation, debugging, cleanup
@@ -27,7 +28,8 @@ int mkd_cleanup(MMIOT*);
 int mkd_dump(MMIOT*, FILE*, int, char*);
 int markdown(MMIOT*, FILE*, mkd_flag_t);
 int mkd_line(char *, int, char **, mkd_flag_t);
-void mkd_string_to_anchor(char *, int, int (*)(int,void*), void*, int);
+typedef int (*mkd_sta_function_t)(const int,const void*);
+void mkd_string_to_anchor(char *, int, mkd_sta_function_t, void*, int);
 int mkd_xhtmlpage(MMIOT*,int,FILE*);
 
 /* header block access
@@ -66,6 +68,9 @@ void mkd_e_data(void *, void *);
 /* version#.
  */
 extern char markdown_version[];
+void mkd_mmiot_flags(FILE *, MMIOT *, int);
+void mkd_flags_are(FILE*, mkd_flag_t, int);
+
 
 /* special flags for markdown() and mkd_text()
  */
@@ -91,6 +96,7 @@ extern char markdown_version[];
 #define MKD_NODIVQUOTE	0x00040000	/* forbid >%class% blocks */
 #define MKD_NOALPHALIST	0x00080000	/* forbid alphabetic lists */
 #define MKD_NODLIST	0x00100000	/* forbid definition lists */
+#define MKD_EXTRA_FOOTNOTE 0x00200000	/* enable markdown extra-style footnotes */
 #define MKD_EMBED	MKD_NOLINKS|MKD_NOIMAGE|MKD_TAGTEXT
 
 /* special flags for mkd_in() and mkd_string()
diff --git a/tests/extrafootnotes.t b/tests/extrafootnotes.t
new file mode 100644
index 0000000..2dfaef4
--- /dev/null
+++ b/tests/extrafootnotes.t
@@ -0,0 +1,25 @@
+. tests/functions.sh
+
+title "markdown extra-style footnotes"
+
+rc=0
+MARKDOWN_FLAGS=
+
+FOOTIE='I haz a footnote[^1]
+[^1]: yes?'
+
+try -ffootnote 'footnotes (-ffootnote)' "$FOOTIE" \
+'<p>I haz a footnote<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup></p>
+<div class="footnotes">
+<hr/>
+<ol>
+<li id="fn:1">
+<p>yes?<a href="#fnref:1" rev="footnote">↩</a></p></li>
+</ol>
+</div>'
+
+try -fnofootnote 'footnotes (-fnofootnote)' "$FOOTIE" \
+'<p>I haz a footnote<a href="yes?">^1</a></p>'
+
+summary $0
+exit $rc
diff --git a/toc.c b/toc.c
index f790614..7048752 100644
--- a/toc.c
+++ b/toc.c
@@ -52,10 +52,12 @@ mkd_toc(Document *p, char **doc)
 		    }
 		    Csprintf(&res, "%*s<li><a href=\"#", srcp->hnumber, "");
 		    mkd_string_to_anchor(T(srcp->text->text),
-					 S(srcp->text->text), Csputc, &res,1);
+					 S(srcp->text->text),
+					 (mkd_sta_function_t)Csputc, &res,1);
 		    Csprintf(&res, "\">");
 		    mkd_string_to_anchor(T(srcp->text->text),
-					 S(srcp->text->text), Csputc, &res,0);
+					 S(srcp->text->text),
+					 (mkd_sta_function_t)Csputc, &res,0);
 		    Csprintf(&res, "</a>");
 		    Csprintf(&res, "</li>\n");
 		}

-- 
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