generate.c (discount-2.2.3a.tar.bz2) | : | generate.c (discount-2.2.4.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 1587 | skipping to change at line 1587 | |||
Qstring("</tbody>\n", f); | Qstring("</tbody>\n", f); | |||
Qstring("</table>\n", f); | Qstring("</table>\n", f); | |||
DELETE(align); | DELETE(align); | |||
return 1; | return 1; | |||
} | } | |||
static int | static int | |||
printblock(Paragraph *pp, MMIOT *f) | printblock(Paragraph *pp, MMIOT *f) | |||
{ | { | |||
Line *t = pp->text; | ||||
static char *Begin[] = { "", "<p>", "<p style=\"text-align:center;\">" }; | static char *Begin[] = { "", "<p>", "<p style=\"text-align:center;\">" }; | |||
static char *End[] = { "", "</p>","</p>" }; | static char *End[] = { "", "</p>","</p>" }; | |||
Line *t = pp->text; | ||||
int align = pp->align; | ||||
while (t) { | while (t) { | |||
if ( S(t->text) ) { | if ( S(t->text) ) { | |||
if ( t->next && S(t->text) > 2 | if ( t->next && S(t->text) > 2 | |||
&& T(t->text)[S(t->text)-2] == ' ' | && T(t->text)[S(t->text)-2] == ' ' | |||
&& T(t->text)[S(t->text)-1] == ' ' ) { | && T(t->text)[S(t->text)-1] == ' ' ) { | |||
push(T(t->text), S(t->text)-2, f); | push(T(t->text), S(t->text)-2, f); | |||
pushc(MKD_EOLN, f); | pushc(MKD_EOLN, f); | |||
pushc('\n', f); | pushc('\n', f); | |||
} | } | |||
else { | else { | |||
___mkd_tidy(&t->text); | ___mkd_tidy(&t->text); | |||
push(T(t->text), S(t->text), f); | push(T(t->text), S(t->text), f); | |||
if ( t->next ) | if ( t->next ) | |||
pushc('\n', f); | pushc('\n', f); | |||
} | } | |||
} | } | |||
t = t->next; | t = t->next; | |||
} | } | |||
Qstring(Begin[pp->align], f); | Qstring(Begin[align], f); | |||
text(f); | text(f); | |||
Qstring(End[pp->align], f); | Qstring(End[align], f); | |||
return 1; | return 1; | |||
} | } | |||
static void | static void | |||
printcode(Line *t, char *lang, MMIOT *f) | printcode(Line *t, char *lang, MMIOT *f) | |||
{ | { | |||
int blanks; | int blanks; | |||
Qstring("<pre><code", f); | Qstring("<pre><code", f); | |||
if (lang) { | if (lang) { | |||
skipping to change at line 1659 | skipping to change at line 1660 | |||
Qchar('\n', f); | Qchar('\n', f); | |||
Qwrite(T(t->text), S(t->text), f); | Qwrite(T(t->text), S(t->text), f); | |||
Qchar('\n', f); | Qchar('\n', f); | |||
} | } | |||
else | else | |||
blanks++; | blanks++; | |||
} | } | |||
static void | static void | |||
htmlify(Paragraph *p, char *block, char *arguments, MMIOT *f) | htmlify_paragraphs(Paragraph *p, MMIOT *f) | |||
{ | { | |||
___mkd_emblock(f); | ___mkd_emblock(f); | |||
if ( block ) | ||||
Qprintf(f, arguments ? "<%s %s>" : "<%s>", block, arguments); | ||||
___mkd_emblock(f); | ||||
while (( p = display(p, f) )) { | while (( p = display(p, f) )) { | |||
___mkd_emblock(f); | ___mkd_emblock(f); | |||
Qstring("\n\n", f); | Qstring("\n\n", f); | |||
} | } | |||
} | ||||
#ifdef GITHUB_CHECKBOX | ||||
static void | ||||
li_htmlify(Paragraph *p, char *arguments, int flags, MMIOT *f) | ||||
{ | ||||
___mkd_emblock(f); | ||||
Qprintf(f, "<li"); | ||||
if ( arguments ) | ||||
Qprintf(f, " %s", arguments); | ||||
if ( flags & GITHUB_CHECK ) | ||||
Qprintf(f, " class=\"github_checkbox\""); | ||||
Qprintf(f, ">"); | ||||
#if CHECKBOX_AS_INPUT | ||||
if ( flags & GITHUB_CHECK ) { | ||||
Qprintf(f, "<input disabled=\"\" type=\"checkbox\""); | ||||
if ( flags & IS_CHECKED ) | ||||
Qprintf(f, " checked=\"checked\""); | ||||
Qprintf(f, "/>"); | ||||
} | ||||
#else | ||||
if ( flags & GITHUB_CHECK ) | ||||
Qprintf(f, flags & IS_CHECKED ? "☑" : "☐"); | ||||
#endif | ||||
htmlify_paragraphs(p, f); | ||||
Qprintf(f, "</li>"); | ||||
___mkd_emblock(f); | ||||
} | ||||
#endif | ||||
static void | ||||
htmlify(Paragraph *p, char *block, char *arguments, MMIOT *f) | ||||
{ | ||||
___mkd_emblock(f); | ||||
if ( block ) | ||||
Qprintf(f, arguments ? "<%s %s>" : "<%s>", block, arguments); | ||||
htmlify_paragraphs(p, f); | ||||
if ( block ) | if ( block ) | |||
Qprintf(f, "</%s>", block); | Qprintf(f, "</%s>", block); | |||
___mkd_emblock(f); | ___mkd_emblock(f); | |||
} | } | |||
static void | static void | |||
definitionlist(Paragraph *p, MMIOT *f) | definitionlist(Paragraph *p, MMIOT *f) | |||
{ | { | |||
Line *tag; | Line *tag; | |||
skipping to change at line 1709 | skipping to change at line 1748 | |||
static void | static void | |||
listdisplay(int typ, Paragraph *p, MMIOT* f) | listdisplay(int typ, Paragraph *p, MMIOT* f) | |||
{ | { | |||
if ( p ) { | if ( p ) { | |||
Qprintf(f, "<%cl", (typ==UL)?'u':'o'); | Qprintf(f, "<%cl", (typ==UL)?'u':'o'); | |||
if ( typ == AL ) | if ( typ == AL ) | |||
Qprintf(f, " type=\"a\""); | Qprintf(f, " type=\"a\""); | |||
Qprintf(f, ">\n"); | Qprintf(f, ">\n"); | |||
for ( ; p ; p = p->next ) { | for ( ; p ; p = p->next ) { | |||
#ifdef GITHUB_CHECKBOX | ||||
li_htmlify(p->down, p->ident, p->flags, f); | ||||
#else | ||||
htmlify(p->down, "li", p->ident, f); | htmlify(p->down, "li", p->ident, f); | |||
#endif | ||||
Qchar('\n', f); | Qchar('\n', f); | |||
} | } | |||
Qprintf(f, "</%cl>\n", (typ==UL)?'u':'o'); | Qprintf(f, "</%cl>\n", (typ==UL)?'u':'o'); | |||
} | } | |||
} | } | |||
/* dump out a Paragraph in the desired manner | /* dump out a Paragraph in the desired manner | |||
*/ | */ | |||
static Paragraph* | static Paragraph* | |||
skipping to change at line 1791 | skipping to change at line 1834 | |||
if ( m->footnotes->reference == 0 ) | if ( m->footnotes->reference == 0 ) | |||
return; | return; | |||
Csprintf(&m->out, "\n<div class=\"footnotes\">\n<hr/>\n<ol>\n"); | Csprintf(&m->out, "\n<div class=\"footnotes\">\n<hr/>\n<ol>\n"); | |||
for ( i=1; i <= m->footnotes->reference; i++ ) { | for ( i=1; i <= m->footnotes->reference; i++ ) { | |||
for ( j=0; j < S(m->footnotes->note); j++ ) { | for ( j=0; j < S(m->footnotes->note); j++ ) { | |||
t = &T(m->footnotes->note)[j]; | t = &T(m->footnotes->note)[j]; | |||
if ( (t->refnumber == i) && (t->flags & REFERENCED) ) { | if ( (t->refnumber == i) && (t->flags & REFERENCED) ) { | |||
Csprintf(&m->out, "<li id=\"%s:%d\">\n<p>", | Csprintf(&m->out, "<li id=\"%s:%d\">\n", | |||
p_or_nothing(m), t->refnumber); | p_or_nothing(m), t->refnumber); | |||
Csreparse(&m->out, T(t->title), S(t->title), 0); | htmlify(t->text, 0, 0, m); | |||
Csprintf(&m->out, "<a href=\"#%sref:%d\" rev=\"footnote\">↩ </a>", | Csprintf(&m->out, "<a href=\"#%sref:%d\" rev=\"footnote\">↩ </a>", | |||
p_or_nothing(m), t->refnumber); | p_or_nothing(m), t->refnumber); | |||
Csprintf(&m->out, "</p></li>\n"); | Csprintf(&m->out, "</li>\n"); | |||
} | } | |||
} | } | |||
} | } | |||
Csprintf(&m->out, "</ol>\n</div>\n"); | Csprintf(&m->out, "</ol>\n</div>\n"); | |||
} | } | |||
/* return a pointer to the compiled markdown | /* return a pointer to the compiled markdown | |||
* document. | * document. | |||
*/ | */ | |||
int | int | |||
End of changes. 12 change blocks. | ||||
10 lines changed or deleted | 53 lines changed or added |