From b708bb98ef8a3ca310ce49ccf94c1e5664732066 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= ", " " };
- static char *End[] = { "", "\n");
- for (i=0; i < NR(flagnames); i++) {
- set = flags & flagnames[i].flag;
- name = flagnames[i].name;
- if ( not = (*name == '!') ) {
- ++name;
- set = !set;
- }
-
- if ( htmlplease ) {
- if ( even ) fprintf(f, "
\n");
- }
-}
-
-void
-mkd_mmiot_flags(FILE *f, MMIOT *m, int htmlplease)
-{
- if ( m )
- mkd_flags_are(f, m->flags, htmlplease);
-}
diff --git a/deps/discount/generate.c b/deps/discount/generate.c
deleted file mode 100644
index 2516a09..0000000
--- a/deps/discount/generate.c
+++ /dev/null
@@ -1,1827 +0,0 @@
-/* markdown: a C implementation of John Gruber's Markdown markup language.
- *
- * Copyright (C) 2007 David L Parsons.
- * The redistribution terms are provided in the COPYRIGHT file that must
- * be distributed with this source code.
- */
-#include ");
- fprintf(f, " \n");
- }
- even = !even;
- }
- if ( htmlplease ) {
- if ( even ) fprintf(f, "\n");
- fprintf(f, "");
- }
- else
- fputc(' ', f);
-
- if ( !set )
- fprintf(f, htmlplease ? " ");
- if ( !even ) fprintf(f, "" : "!");
-
- fprintf(f, "%s", name);
-
- if ( htmlplease ) {
- if ( !set )
- fprintf(f, "");
- fprintf(f, "...
- */
-static void
-delspan(MMIOT *f, int size)
-{
- Qstring("", f);
- ___mkd_reparse(cursor(f)-1, size, 0, f, 0);
- Qstring("", f);
-}
-
-
-/* codespan() -- write out a chunk of text as code, trimming one
- * space off the front and/or back as appropriate.
- */
-static void
-codespan(MMIOT *f, int size)
-{
- int i=0;
-
- if ( size > 1 && peek(f, size-1) == ' ' ) --size;
- if ( peek(f,i) == ' ' ) ++i, --size;
-
- Qstring("", f);
- code(f, cursor(f)+(i-1), size);
- Qstring("
", f);
-} /* codespan */
-
-
-/* before letting a tag through, validate against
- * MKD_NOLINKS and MKD_NOIMAGE
- */
-static int
-forbidden_tag(MMIOT *f)
-{
- int c = toupper(peek(f, 1));
-
- if ( f->flags & MKD_NOHTML )
- return 1;
-
- if ( c == 'A' && (f->flags & MKD_NOLINKS) && !isthisalnum(f,2) )
- return 1;
- if ( c == 'I' && (f->flags & MKD_NOIMAGE)
- && strncasecmp(cursor(f)+1, "MG", 2) == 0
- && !isthisalnum(f,4) )
- return 1;
- return 0;
-}
-
-
-/* Check a string to see if it looks like a mail address
- * "looks like a mail address" means alphanumeric + some
- * specials, then a `@`, then alphanumeric + some specials,
- * but with a `.`
- */
-static int
-maybe_address(char *p, int size)
-{
- int ok = 0;
-
- for ( ;size && (isalnum(*p) || strchr("._-+*", *p)); ++p, --size)
- ;
-
- if ( ! (size && *p == '@') )
- return 0;
-
- --size, ++p;
-
- if ( size && *p == '.' ) return 0;
-
- for ( ;size && (isalnum(*p) || strchr("._-+", *p)); ++p, --size )
- if ( *p == '.' && size > 1 ) ok = 1;
-
- return size ? 0 : ok;
-}
-
-
-/* The size-length token at cursor(f) is either a mailto:, an
- * implicit mailto:, one of the approved url protocols, or just
- * plain old text. If it's a mailto: or an approved protocol,
- * linkify it, otherwise say "no"
- */
-static int
-process_possible_link(MMIOT *f, int size)
-{
- int address= 0;
- int mailto = 0;
- char *text = cursor(f);
-
- if ( f->flags & MKD_NOLINKS ) return 0;
-
- if ( (size > 7) && strncasecmp(text, "mailto:", 7) == 0 ) {
- /* if it says it's a mailto, it's a mailto -- who am
- * I to second-guess the user?
- */
- address = 1;
- mailto = 7; /* 7 is the length of "mailto:"; we need this */
- }
- else
- address = maybe_address(text, size);
-
- if ( address ) {
- Qstring("", f);
- mangle(text+mailto, size-mailto, f);
- Qstring("", f);
- return 1;
- }
- else if ( isautoprefix(text, size) ) {
- printlinkyref(f, &linkt, text, size);
- Qchar('>', f);
- puturl(text,size,f, 1);
- Qstring("
", f);
- break;
-
- case '>': if ( tag_text(f) )
- Qstring(">", f);
- else
- Qchar(c, f);
- break;
-
- case '"': if ( tag_text(f) )
- Qstring(""", f);
- else
- Qchar(c, f);
- break;
-
- case '!': if ( peek(f,1) == '[' ) {
- pull(f);
- if ( tag_text(f) || !linkylinky(1, f) )
- Qstring("![", f);
- }
- else
- Qchar(c, f);
- break;
- case '[': if ( tag_text(f) || !linkylinky(0, f) )
- Qchar(c, f);
- break;
- /* A^B -> AB */
- case '^': if ( (f->flags & (MKD_NOSUPERSCRIPT|MKD_STRICT|MKD_TAGTEXT))
- || (isthisnonword(f,-1) && peek(f,-1) != ')')
- || isthisspace(f,1) )
- Qchar(c,f);
- else {
- char *sup = cursor(f);
- int len = 0;
-
- if ( peek(f,1) == '(' ) {
- int here = mmiottell(f);
- pull(f);
-
- if ( (len = parenthetical('(',')',f)) <= 0 ) {
- mmiotseek(f,here);
- Qchar(c, f);
- break;
- }
- sup++;
- }
- else {
- while ( isthisalnum(f,1+len) )
- ++len;
- if ( !len ) {
- Qchar(c,f);
- break;
- }
- shift(f,len);
- }
- Qstring("",f);
- ___mkd_reparse(sup, len, 0, f, "()");
- Qstring("", f);
- }
- break;
- case '_':
- /* Underscores don't count if they're in the middle of a word */
- if ( !(f->flags & (MKD_NORELAXED|MKD_STRICT))
- && isthisalnum(f,-1)
- && isthisalnum(f,1) ) {
- Qchar(c, f);
- break;
- }
- case '*':
- /* Underscores & stars don't count if they're out in the middle
- * of whitespace */
- if ( isthisspace(f,-1) && isthisspace(f,1) ) {
- Qchar(c, f);
- break;
- }
- /* else fall into the regular old emphasis case */
- if ( tag_text(f) )
- Qchar(c, f);
- else {
- for (rep = 1; peek(f,1) == c; pull(f) )
- ++rep;
- Qem(f,c,rep);
- }
- break;
-
- 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,1,codespan) )
- Qchar(c, f);
- break;
-
- case '\\': switch ( c = pull(f) ) {
- case '&': Qstring("&", f);
- break;
- case '<': c = peek(f,1);
- if ( (c == EOF) || isspace(c) )
- Qstring("<", f);
- else {
- /* Markdown.pl does not escape <[nonwhite]
- * sequences */
- Qchar('\\', f);
- shift(f, -1);
- }
-
- break;
- case '^': if ( f->flags & (MKD_STRICT|MKD_NOSUPERSCRIPT) ) {
- Qchar('\\', f);
- shift(f,-1);
- break;
- }
- Qchar(c, f);
- break;
-
- case ':': case '|':
- if ( f->flags & MKD_NOTABLES ) {
- Qchar('\\', f);
- shift(f,-1);
- break;
- }
- Qchar(c, f);
- break;
-
- case EOF: Qchar('\\', f);
- break;
-
- default: if ( escaped(f,c) ||
- strchr(">#.-+{}]![*_\\()`", c) )
- Qchar(c, f);
- else {
- Qchar('\\', f);
- shift(f, -1);
- }
- break;
- }
- break;
-
- case '<': if ( !maybe_tag_or_link(f) )
- Qstring("<", f);
- break;
-
- case '&': j = (peek(f,1) == '#' ) ? 2 : 1;
- while ( isthisalnum(f,j) )
- ++j;
-
- if ( peek(f,j) != ';' )
- Qstring("&", f);
- else
- Qchar(c, f);
- break;
-
- default: Qchar(c, f);
- break;
- }
- }
- /* truncate the input string after we've finished processing it */
- S(f->in) = f->isp = 0;
-} /* text */
-
-
-/* print a header block
- */
-static void
-printheader(Paragraph *pp, MMIOT *f)
-{
-#if WITH_ID_ANCHOR
- Qprintf(f, "\n", f);
- while ( idx < S(p->text) ) {
- first = idx;
- if ( force && (colno >= S(align)-1) )
- idx = S(p->text);
- else
- while ( (idx < S(p->text)) && (T(p->text)[idx] != '|') ) {
- if ( T(p->text)[idx] == '\\' )
- ++idx;
- ++idx;
- }
-
- Qprintf(f, "<%s%s>",
- block,
- alignments[ (colno < S(align)) ? T(align)[colno] : a_NONE ]);
- ___mkd_reparse(T(p->text)+first, idx-first, 0, f, "|");
- Qprintf(f, "%s>\n", block);
- idx++;
- colno++;
- }
- if ( force )
- while (colno < S(align) ) {
- Qprintf(f, "<%s>%s>\n", block, block);
- ++colno;
- }
- Qstring(" \n", f);
- return colno;
-}
-
-
-static int
-printtable(Paragraph *pp, MMIOT *f)
-{
- /* header, dashes, then lines of content */
-
- Line *hdr, *dash, *body;
- Istring align;
- int hcols,start;
- char *p;
- enum e_alignments it;
-
- hdr = pp->text;
- dash= hdr->next;
- body= dash->next;
-
- if ( T(hdr->text)[hdr->dle] == '|' ) {
- /* trim leading pipe off all lines
- */
- Line *r;
- for ( r = pp->text; r; r = r->next )
- r->dle ++;
- }
-
- /* figure out cell alignments */
-
- CREATE(align);
-
- for (p=T(dash->text), start=dash->dle; start < S(dash->text); ) {
- char first, last;
- int end;
-
- last=first=0;
- for (end=start ; (end < S(dash->text)) && p[end] != '|'; ++ end ) {
- if ( p[end] == '\\' )
- ++ end;
- else if ( !isspace(p[end]) ) {
- if ( !first) first = p[end];
- last = p[end];
- }
- }
- it = ( first == ':' ) ? (( last == ':') ? a_CENTER : a_LEFT)
- : (( last == ':') ? a_RIGHT : a_NONE );
-
- EXPAND(align) = it;
- start = 1+end;
- }
-
- Qstring("\n", f);
- Qstring("\n", f);
- hcols = splat(hdr, "th", align, 0, f);
- Qstring("\n", f);
-
- if ( hcols < S(align) )
- S(align) = hcols;
- else
- while ( hcols > S(align) )
- EXPAND(align) = a_NONE;
-
- Qstring("\n", f);
- for ( ; body; body = body->next)
- splat(body, "td", align, 1, f);
- Qstring("\n", f);
- Qstring("
\n", f);
-
- DELETE(align);
- return 1;
-}
-
-
-static int
-printblock(Paragraph *pp, MMIOT *f)
-{
- Line *t = pp->text;
- static char *Begin[] = { "", "
", f);
- for ( blanks = 0; t ; t = t->next ) {
- if ( S(t->text) > t->dle ) {
- while ( blanks ) {
- Qchar('\n', f);
- --blanks;
- }
- code(f, T(t->text), S(t->text));
- Qchar('\n', f);
- }
- else blanks++;
- }
- Qstring("
", f);
-}
-
-
-static void
-printhtml(Line *t, MMIOT *f)
-{
- int blanks;
-
- for ( blanks=0; t ; t = t->next )
- if ( S(t->text) ) {
- for ( ; blanks; --blanks )
- Qchar('\n', f);
-
- Qwrite(T(t->text), S(t->text), f);
- Qchar('\n', f);
- }
- else
- blanks++;
-}
-
-
-static void
-htmlify(Paragraph *p, char *block, char *arguments, MMIOT *f)
-{
- ___mkd_emblock(f);
- if ( block )
- Qprintf(f, arguments ? "<%s %s>" : "<%s>", block, arguments);
- ___mkd_emblock(f);
-
- while (( p = display(p, f) )) {
- ___mkd_emblock(f);
- Qstring("\n\n", f);
- }
-
- if ( block )
- Qprintf(f, "%s>", block);
- ___mkd_emblock(f);
-}
-
-
-static void
-definitionlist(Paragraph *p, MMIOT *f)
-{
- Line *tag;
-
- if ( p ) {
- Qstring("", - p_or_nothing(m), t->refnumber); - Csreparse(&m->out, T(t->title), S(t->title), 0); - Csprintf(&m->out, "↩", - p_or_nothing(m), t->refnumber); - Csprintf(&m->out, "
header | -header | -
---|---|
text | -text | -