Commit 24edcbbe authored by Alessandro Ghedini's avatar Alessandro Ghedini

Imported Upstream version 2.1.3

parent 8d8efc1d
......@@ -22,49 +22,52 @@ 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)
@INSTALL_PROGRAM@ $(PGMS) $(DESTDIR)/$(BINDIR)
./librarian.sh install libmarkdown VERSION $(DESTDIR)/$(LIBDIR)
@INSTALL_DATA@ mkdio.h $(DESTDIR)/$(INCDIR)
install: $(PGMS) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCDIR)
@INSTALL_PROGRAM@ $(PGMS) $(DESTDIR)$(BINDIR)
./librarian.sh install libmarkdown VERSION $(DESTDIR)$(LIBDIR)
@INSTALL_DATA@ mkdio.h $(DESTDIR)$(INCDIR)
install.everything: install install.samples install.man
install.samples: $(SAMPLE_PGMS) install $(DESTDIR)/$(BINDIR)
@INSTALL_PROGRAM@ $(SAMPLE_PGMS) $(DESTDIR)/$(BINDIR)
@INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man1
@INSTALL_DATA@ theme.1 makepage.1 mkd2html.1 $(DESTDIR)/$(MANDIR)/man1
install.samples: $(SAMPLE_PGMS) install $(DESTDIR)$(BINDIR)
@INSTALL_PROGRAM@ $(SAMPLE_PGMS) $(DESTDIR)$(BINDIR)
@INSTALL_DIR@ $(DESTDIR)$(MANDIR)/man1
@INSTALL_DATA@ theme.1 makepage.1 mkd2html.1 $(DESTDIR)$(MANDIR)/man1
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;\
( echo '.\"' ; echo ".so man3/mkd-line.3" ) > $(DESTDIR)$(MANDIR)/man3/$$x.3;\
done
for x in mkd_in mkd_string; do \
( echo '.\"' ; echo ".so man3/markdown.3" ) > $(DESTDIR)/$(MANDIR)/man3/$$x.3;\
( echo '.\"' ; echo ".so man3/markdown.3" ) > $(DESTDIR)$(MANDIR)/man3/$$x.3;\
done
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; \
( 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)
$(DESTDIR)$(BINDIR):
@INSTALL_DIR@ $(DESTDIR)$(BINDIR)
$(DESTDIR)/$(INCDIR):
@INSTALL_DIR@ $(DESTDIR)/$(INCDIR)
$(DESTDIR)$(INCDIR):
@INSTALL_DIR@ $(DESTDIR)$(INCDIR)
$(DESTDIR)/$(LIBDIR):
@INSTALL_DIR@ $(DESTDIR)/$(LIBDIR)
$(DESTDIR)$(LIBDIR):
@INSTALL_DIR@ $(DESTDIR)$(LIBDIR)
version.o: version.c VERSION
$(CC) -DVERSION=\"`cat VERSION`\" -c version.c
VERSION:
@true
tags.o: tags.c blocktags
blocktags: mktags
......
......@@ -385,7 +385,10 @@ EOF
TLOGN " ($AC_CC)"
if [ $status -eq 0 ]; then
if $AC_CC -v 2>&1 | grep 'gcc version' >/dev/null; then
if $AC_CC -x c /dev/null -dM -E 2>&1 | grep '__clang__' >/dev/null; then
TLOG " yuck, you're using clang"
IS_BROKEN_CC=T
elif $AC_CC -v 2>&1 | grep 'gcc version' >/dev/null; then
TLOG " oh ick, it looks like gcc"
IS_BROKEN_CC=T
else
......@@ -874,7 +877,6 @@ say(char *w, char *v)
: "s:@%s@:%s:g\n", w, v);
}
void
main(argc, argv)
char **argv;
{
......@@ -1177,7 +1179,7 @@ main()
EOF
if $AC_CC -o ngc$$ ngc$$.c $LIBS; then
if ngc$$; then
if ./ngc$$; then
TLOG "(found)"
AC_DEFINE 'HAVE_BASENAME' 1
AC_CHECK_HEADERS libgen.h
......
......@@ -1403,14 +1403,13 @@ static char* alignments[] = { "", " align=\"center\"", " align=\"left\"",
typedef STRING(int) Istring;
static int
splat(Line *p, int leading_pipe, char *block, Istring align, int force, MMIOT *f)
splat(Line *p, char *block, Istring align, int force, MMIOT *f)
{
int first,
idx = p->dle,
colno = 0;
if ( leading_pipe ) idx++;
___mkd_tidy(&p->text);
if ( T(p->text)[S(p->text)-1] == '|' )
--S(p->text);
......@@ -1452,20 +1451,27 @@ printtable(Paragraph *pp, MMIOT *f)
Line *hdr, *dash, *body;
Istring align;
int hcols,start,starts_with_pipe=0;
int hcols,start;
char *p;
enum e_alignments it;
hdr = pp->text;
dash= hdr->next;
body= dash->next;
starts_with_pipe = T(hdr->text)[hdr->dle] == '|';
if ( T(hdr->text)[hdr->dle] == '|' ) {
/* trim leading pipe off all lines
*/
Line *r;
for ( r = pp->text; r; r = r->next )
r->dle ++;
}
/* first figure out cell alignments */
/* figure out cell alignments */
CREATE(align);
for (p=T(dash->text), start=0; start < S(dash->text); ) {
for (p=T(dash->text), start=dash->dle; start < S(dash->text); ) {
char first, last;
int end;
......@@ -1478,14 +1484,16 @@ printtable(Paragraph *pp, MMIOT *f)
last = p[end];
}
}
EXPAND(align) = ( first == ':' ) ? (( last == ':') ? a_CENTER : a_LEFT)
: (( last == ':') ? a_RIGHT : a_NONE );
it = ( first == ':' ) ? (( last == ':') ? a_CENTER : a_LEFT)
: (( last == ':') ? a_RIGHT : a_NONE );
EXPAND(align) = it;
start = 1+end;
}
Qstring("<table>\n", f);
Qstring("<thead>\n", f);
hcols = splat(hdr, starts_with_pipe, "th", align, 0, f);
hcols = splat(hdr, "th", align, 0, f);
Qstring("</thead>\n", f);
if ( hcols < S(align) )
......@@ -1496,7 +1504,7 @@ printtable(Paragraph *pp, MMIOT *f)
Qstring("<tbody>\n", f);
for ( ; body; body = body->next)
splat(body, starts_with_pipe, "td", align, 1, f);
splat(body, "td", align, 1, f);
Qstring("</tbody>\n", f);
Qstring("</table>\n", f);
......
......@@ -59,7 +59,6 @@ complain(char *fmt, ...)
}
float
main(int argc, char **argv)
{
int opt;
......
......@@ -22,7 +22,6 @@ basename(char *p)
char *pgm = "makepage";
float
main(argc, argv)
int argc;
char **argv;
......
......@@ -65,7 +65,6 @@ fail(char *why, ...)
}
void
main(argc, argv)
char **argv;
{
......
......@@ -41,7 +41,6 @@ typedef int (*stfu)(const void*,const void*);
/* load in the standard collection of html tags that markdown supports
*/
int
main()
{
int i;
......@@ -76,7 +75,6 @@ main()
KW("WBR");
KW("XMP");
SC("HR");
SC("BR");
KW("IFRAME");
KW("MAP");
......
. tests/functions.sh
title "reported defects"
rc=0
MARKDOWN_FLAGS=
try 'masses of non-block html' \
'<span>foo</span><br>
<br>
<span>bar</span><br>' \
'<p><span>foo</span><br>
<br>
<span>bar</span><br></p>'
summary $0
exit $rc
......@@ -21,15 +21,6 @@ text' \
'<hr/>
<p>text</p>'
try 'self-closing block tags (br)' \
'<br>
text' \
'<br>
<p>text</p>'
try 'html comments' \
......
......@@ -250,5 +250,27 @@ try "table with flanking |'s" \
</tbody>
</table>'
try "table with leading |'s and alignment" \
'|AA|BB|CC
|:-|::|-:
|aa|bb|cc' \
'<table>
<thead>
<tr>
<th align="left">AA</th>
<th align="center">BB</th>
<th align="right">CC</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">aa</td>
<td align="center">bb</td>
<td align="right">cc</td>
</tr>
</tbody>
</table>'
summary $0
exit $rc
......@@ -23,9 +23,11 @@ hi' \
try '-T -ftoc' 'toc item with link' \
'##[H2](H2) here' \
'<ul>
<li><ul>
<li>
<ul>
<li><a href="#H2.here">H2 here</a></li>
</ul></li>
</ul>
</li>
</ul>
<h2 id="H2.here"><a href="H2">H2</a> here</h2>'
......@@ -56,9 +58,11 @@ hi' \
try '-T -ftoc' 'toc item with link' \
'##[H2](H2) here' \
'<ul>
<li><ul>
<li>
<ul>
<li><a href="#H2.here">H2 here</a></li>
</ul></li>
</ul>
</li>
</ul>
<a name="H2.here"></a>
<h2><a href="H2">H2</a> here</h2>'
......
......@@ -499,7 +499,6 @@ spin(FILE *template, MMIOT *doc, FILE *output)
} /* spin */
void
main(argc, argv)
char **argv;
{
......
/*
* toc -- spit out a table of contents based on header blocks
*
* Copyright (C) 2008 Jjgod Jiang, David L Parsons.
* Copyright (C) 2008 Jjgod Jiang, David L Parsons
* portions Copyright (C) 2011 Stefano D'Angelo
* The redistribution terms are provided in the COPYRIGHT file that must
* be distributed with this source code.
*/
......@@ -23,6 +24,7 @@ mkd_toc(Document *p, char **doc)
int last_hnumber = 0;
Cstring res;
int size;
int first = 1;
if ( !(doc && p && p->ctx) ) return -1;
......@@ -38,16 +40,23 @@ mkd_toc(Document *p, char **doc)
for ( srcp = tp->down; srcp; srcp = srcp->next ) {
if ( srcp->typ == HDR && srcp->text ) {
if ( last_hnumber >= srcp->hnumber ) {
while ( last_hnumber > srcp->hnumber ) {
Csprintf(&res, "%*s</ul></li>\n", last_hnumber-1,"");
--last_hnumber;
}
while ( last_hnumber > srcp->hnumber ) {
if ( (last_hnumber - srcp->hnumber) > 1 )
Csprintf(&res, "\n");
Csprintf(&res, "</li>\n%*s</ul>\n%*s",
last_hnumber-1, "", last_hnumber-1, "");
--last_hnumber;
}
if ( last_hnumber == srcp->hnumber )
Csprintf(&res, "</li>\n");
else if ( (srcp->hnumber > last_hnumber) && !first )
Csprintf(&res, "\n");
while ( srcp->hnumber > last_hnumber ) {
Csprintf(&res, "%*s%s<ul>\n", last_hnumber, "",
last_hnumber ? "<li>" : "");
Csprintf(&res, "%*s<ul>\n", last_hnumber, "");
if ( (srcp->hnumber - last_hnumber) > 1 )
Csprintf(&res, "%*s<li>\n", last_hnumber+1, "");
++last_hnumber;
}
Csprintf(&res, "%*s<li><a href=\"#", srcp->hnumber, "");
......@@ -59,7 +68,8 @@ mkd_toc(Document *p, char **doc)
S(srcp->text->text),
(mkd_sta_function_t)Csputc, &res,0);
Csprintf(&res, "</a>");
Csprintf(&res, "</li>\n");
first = 0;
}
}
}
......@@ -67,7 +77,8 @@ mkd_toc(Document *p, char **doc)
while ( last_hnumber > 0 ) {
--last_hnumber;
Csprintf(&res, last_hnumber ? "%*s</ul></li>\n" : "%*s</ul>\n", last_hnumber, "");
Csprintf(&res, "</li>\n%*s</ul>\n%*s",
last_hnumber, "", last_hnumber, "");
}
if ( (size = S(res)) > 0 ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment