[Reproducible-commits] [discount] 45/121: Imported Upstream version 2.1.2
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 8d8efc1dfb19d3f010496dc2eae901dbdf790761
Author: Alessandro Ghedini <al3xbio at gmail.com>
Date: Wed Sep 28 16:12:07 2011 +0200
Imported Upstream version 2.1.2
---
CREDITS | 2 +
VERSION | 2 +-
generate.c | 22 ++++++-----
markdown.c | 119 ++++++++++++++++++++++++++-------------------------------
tests/tables.t | 57 +++++++++++++++++++++++----
5 files changed, 121 insertions(+), 81 deletions(-)
diff --git a/CREDITS b/CREDITS
index 3ec9d8c..2014bc5 100644
--- a/CREDITS
+++ b/CREDITS
@@ -29,5 +29,7 @@ Andrew White -- bug reports about the format of generated urls.
Steve Huff -- bug reports about Makefile portability (for Fink)
Ignacio Burgue?o-- bug reports about `>%class%`
Henrik Nyh -- bug reports about embedded html handling.
+John J. Foerch -- bug reports about incorrect `–` and `—`
+ translations.
diff --git a/VERSION b/VERSION
index 8537c47..eca07e4 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.1.1.3
+2.1.2
diff --git a/generate.c b/generate.c
index d9757e8..0eceae7 100644
--- a/generate.c
+++ b/generate.c
@@ -1403,12 +1403,18 @@ static char* alignments[] = { "", " align=\"center\"", " align=\"left\"",
typedef STRING(int) Istring;
static int
-splat(Line *p, char *block, Istring align, int force, MMIOT *f)
+splat(Line *p, int leading_pipe, char *block, Istring align, int force, MMIOT *f)
{
int first,
- idx = 0,
+ idx = p->dle,
colno = 0;
+
+ if ( leading_pipe ) idx++;
+ ___mkd_tidy(&p->text);
+ if ( T(p->text)[S(p->text)-1] == '|' )
+ --S(p->text);
+
Qstring("<tr>\n", f);
while ( idx < S(p->text) ) {
first = idx;
@@ -1446,17 +1452,15 @@ printtable(Paragraph *pp, MMIOT *f)
Line *hdr, *dash, *body;
Istring align;
- int start;
- int hcols;
+ int hcols,start,starts_with_pipe=0;
char *p;
- if ( !(pp->text && pp->text->next) )
- return 0;
-
hdr = pp->text;
dash= hdr->next;
body= dash->next;
+ starts_with_pipe = T(hdr->text)[hdr->dle] == '|';
+
/* first figure out cell alignments */
CREATE(align);
@@ -1481,7 +1485,7 @@ printtable(Paragraph *pp, MMIOT *f)
Qstring("<table>\n", f);
Qstring("<thead>\n", f);
- hcols = splat(hdr, "th", align, 0, f);
+ hcols = splat(hdr, starts_with_pipe, "th", align, 0, f);
Qstring("</thead>\n", f);
if ( hcols < S(align) )
@@ -1492,7 +1496,7 @@ printtable(Paragraph *pp, MMIOT *f)
Qstring("<tbody>\n", f);
for ( ; body; body = body->next)
- splat(body, "td", align, 1, f);
+ splat(body, starts_with_pipe, "td", align, 1, f);
Qstring("</tbody>\n", f);
Qstring("</table>\n", f);
diff --git a/markdown.c b/markdown.c
index f4966c2..2a8cc65 100644
--- a/markdown.c
+++ b/markdown.c
@@ -319,47 +319,6 @@ htmlblock(Paragraph *p, struct kw *tag, int *unclosed)
}
-/* tables look like
- * header|header{|header}
- * ------|------{|......}
- * {body lines}
- */
-static int
-istable(Line *t)
-{
- char *p;
- Line *dashes, *body;
- int l;
- int dashed = 0;
-
- /* three lines, first must contain |,
- second must be ---|---,
- third must contain |
- */
- if ( !(t->flags & PIPECHAR) )
- return 0;
-
- dashes = t->next;
- if ( !(dashes && (dashes->flags & PIPECHAR)) )
- return 0;
-
- body = dashes->next;
- if ( !(body && (body->flags & PIPECHAR)) )
- return 0;
-
- /* second line must contain - or | and nothing
- * else except for whitespace or :
- */
- for ( p = T(dashes->text), l = S(dashes->text); l > 0; ++p, --l)
- if ( *p == '-' )
- dashed = 1;
- else if ( ! ((*p == '|') || (*p == ':') || isspace(*p)) )
- return 0;
-
- return dashed;
-}
-
-
/* footnotes look like ^<whitespace>{0,3}[stuff]: <content>$
*/
static int
@@ -841,25 +800,6 @@ quoteblock(Paragraph *p, DWORD flags)
}
-/*
- * A table block starts with a table header (see istable()), and continues
- * until EOF or a line that /doesn't/ contain a |.
- */
-static Line *
-tableblock(Paragraph *p)
-{
- Line *t, *q;
-
- for ( t = p->text; t && (q = t->next); t = t->next ) {
- if ( !(t->flags & PIPECHAR) ) {
- t->next = 0;
- return q;
- }
- }
- return 0;
-}
-
-
typedef int (*linefn)(Line *);
@@ -1189,6 +1129,58 @@ compile_document(Line *ptr, MMIOT *f)
}
+static int
+first_nonblank_before(Line *j, int dle)
+{
+ return (j->dle < dle) ? j->dle : dle;
+}
+
+
+static int
+actually_a_table(MMIOT *f, Line *pp)
+{
+ Line *r;
+ int j;
+ int c;
+
+ /* tables need to be turned on */
+ if ( f->flags & (MKD_STRICT|MKD_NOTABLES) )
+ return 0;
+
+ /* tables need three lines */
+ if ( !(pp && pp->next && pp->next->next) ) {
+ return 0;
+ }
+
+ /* all lines must contain |'s */
+ for (r = pp; r; r = r->next )
+ if ( !(r->flags & PIPECHAR) ) {
+ return 0;
+ }
+
+ /* if the header has a leading |, all lines must have leading |'s */
+ if ( T(pp->text)[pp->dle] == '|' ) {
+ for ( r = pp; r; r = r->next )
+ if ( T(r->text)[first_nonblank_before(r,pp->dle)] != '|' ) {
+ return 0;
+ }
+ }
+
+ /* second line must be only whitespace, -, |, or : */
+ r = pp->next;
+
+ for ( j=r->dle; j < S(r->text); ++j ) {
+ c = T(r->text)[j];
+
+ if ( !(isspace(c)||(c=='-')||(c==':')||(c=='|')) ) {
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+
/*
* break a collection of markdown input into
* blocks of lists, code, html, and text to
@@ -1249,13 +1241,12 @@ compile(Line *ptr, int toplevel, MMIOT *f)
p = Pp(&d, ptr, HDR);
ptr = headerblock(p, hdr_type);
}
- else if ( istable(ptr) && !(f->flags & (MKD_STRICT|MKD_NOTABLES)) ) {
- p = Pp(&d, ptr, TABLE);
- ptr = tableblock(p);
- }
else {
p = Pp(&d, ptr, MARKUP);
ptr = textblock(p, toplevel, f->flags);
+ /* tables are a special kind of paragraph */
+ if ( actually_a_table(f, p->text) )
+ p->typ = TABLE;
}
if ( (para||toplevel) && !p->align )
diff --git a/tests/tables.t b/tests/tables.t
index 50f2933..c6a9e95 100644
--- a/tests/tables.t
+++ b/tests/tables.t
@@ -12,13 +12,11 @@ try 'single-column table' \
'<table>
<thead>
<tr>
-<th></th>
<th>hello</th>
</tr>
</thead>
<tbody>
<tr>
-<td></td>
<td>sailor</td>
</tr>
</tbody>
@@ -33,7 +31,7 @@ hello|sailor' \
'<table>
<thead>
<tr>
-<th> a </th>
+<th>a </th>
<th> b</th>
</tr>
</thead>
@@ -75,7 +73,7 @@ hello|
'<table>
<thead>
<tr>
-<th> a </th>
+<th>a </th>
<th> b</th>
</tr>
</thead>
@@ -85,7 +83,7 @@ hello|
<td></td>
</tr>
<tr>
-<td> </td>
+<td></td>
<td>sailor</td>
</tr>
</tbody>
@@ -99,7 +97,7 @@ hello|sailor' \
'<table>
<thead>
<tr>
-<th align="right"> a </th>
+<th align="right">a </th>
<th align="left"> b</th>
</tr>
</thead>
@@ -119,7 +117,7 @@ hello|sailor|boy' \
'<table>
<thead>
<tr>
-<th> a </th>
+<th>a </th>
<th> b</th>
</tr>
</thead>
@@ -207,5 +205,50 @@ CD' \
–|-
CD</p>'
+try 'table followed by text' \
+ '
+A|B
+-|-
+C|D
+
+foo?' \
+'<table>
+<thead>
+<tr>
+<th>A</th>
+<th>B</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>C</td>
+<td>D</td>
+</tr>
+</tbody>
+</table>
+
+
+<p>foo?</p>'
+
+try "table with flanking |'s" \
+'
+|A|B|
+|-|-|
+|D|C|' \
+'<table>
+<thead>
+<tr>
+<th>A</th>
+<th>B</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>D</td>
+<td>C</td>
+</tr>
+</tbody>
+</table>'
+
summary $0
exit $rc
--
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