"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "markdown.c" between
discount-2.2.3a.tar.bz2 and discount-2.2.4.tar.bz2

About: Discount is an implementation of the "Markdown" markup language (written in C).

markdown.c  (discount-2.2.3a.tar.bz2):markdown.c  (discount-2.2.4.tar.bz2)
skipping to change at line 162 skipping to change at line 162
static void static void
splitline(Line *t, int cutpoint) splitline(Line *t, int cutpoint)
{ {
if ( t && (cutpoint < S(t->text)) ) { if ( t && (cutpoint < S(t->text)) ) {
Line *tmp = calloc(1, sizeof *tmp); Line *tmp = calloc(1, sizeof *tmp);
tmp->next = t->next; tmp->next = t->next;
t->next = tmp; t->next = tmp;
tmp->dle = t->dle;
SUFFIX(tmp->text, T(t->text)+cutpoint, S(t->text)-cutpoint); SUFFIX(tmp->text, T(t->text)+cutpoint, S(t->text)-cutpoint);
EXPAND(tmp->text) = 0;
S(tmp->text)--;
S(t->text) = cutpoint; S(t->text) = cutpoint;
} }
} }
#define UNCHECK(l) ((l)->flags &= ~CHECKED) #define UNCHECK(l) ((l)->flags &= ~CHECKED)
#define UNLESS_FENCED(t) if (fenced) { \ #define UNLESS_FENCED(t) if (fenced) { \
other = 1; l->count += (c == ' ' ? 0 : -1); \ other = 1; l->count += (c == ' ' ? 0 : -1); \
} else { t; } } else { t; }
skipping to change at line 583 skipping to change at line 585
} }
return ret; return ret;
} }
static Line * static Line *
codeblock(Paragraph *p) codeblock(Paragraph *p)
{ {
Line *t = p->text, *r; Line *t = p->text, *r;
for ( ; t; t = r ) { for ( ; t; t = r ) {
CLIP(t->text,0,4); __mkd_trim_line(t,4);
t->dle = mkd_firstnonblank(t);
if ( !( (r = skipempty(t->next)) && iscode(r)) ) { if ( !( (r = skipempty(t->next)) && iscode(r)) ) {
___mkd_freeLineRange(t,r); ___mkd_freeLineRange(t,r);
t->next = 0; t->next = 0;
return r; return r;
} }
} }
return t; return t;
} }
skipping to change at line 771 skipping to change at line 772
/* clip leading spaces */ /* clip leading spaces */
for (qp = 0; T(t->text)[qp] != '>'; qp ++) for (qp = 0; T(t->text)[qp] != '>'; qp ++)
/* assert: the first nonblank character on this line /* assert: the first nonblank character on this line
* will be a > * will be a >
*/; */;
/* clip '>' */ /* clip '>' */
qp++; qp++;
/* clip next space, if any */ /* clip next space, if any */
if ( T(t->text)[qp] == ' ' ) if ( T(t->text)[qp] == ' ' )
qp++; qp++;
CLIP(t->text, 0, qp); __mkd_trim_line(t,qp);
UNCHECK(t); UNCHECK(t);
t->dle = mkd_firstnonblank(t);
} }
q = skipempty(t->next); q = skipempty(t->next);
if ( (q == 0) || ((q != t->next) && (!isquote(q) || isdivmarker(q,1,flags ))) ) { if ( (q == 0) || ((q != t->next) && (!isquote(q) || isdivmarker(q,1,flags ))) ) {
___mkd_freeLineRange(t, q); ___mkd_freeLineRange(t, q);
t = q; t = q;
break; break;
} }
} }
skipping to change at line 818 skipping to change at line 818
* runs until the next list marker, the next non-indented paragraph, * runs until the next list marker, the next non-indented paragraph,
* or EOF. You do not have to indent nonblank lines after the list * or EOF. You do not have to indent nonblank lines after the list
* marker, but multiple paragraphs need to start with a 4-space indent. * marker, but multiple paragraphs need to start with a 4-space indent.
*/ */
static Line * static Line *
listitem(Paragraph *p, int indent, DWORD flags, linefn check) listitem(Paragraph *p, int indent, DWORD flags, linefn check)
{ {
Line *t, *q; Line *t, *q;
int clip = indent; int clip = indent;
int z; int z;
#ifdef GITHUB_CHECKBOX
int firstpara = 1;
int ischeck;
#define CHECK_NOT 0
#define CHECK_NO 1
#define CHECK_YES 2
#endif
for ( t = p->text; t ; t = q) { for ( t = p->text; t ; t = q) {
CLIP(t->text, 0, clip);
UNCHECK(t); UNCHECK(t);
t->dle = mkd_firstnonblank(t); __mkd_trim_line(t, clip);
#ifdef GITHUB_CHECKBOX
if ( firstpara ) {
ischeck = CHECK_NOT;
if ( strncmp(T(t->text)+t->dle, "[ ]", 3) == 0 )
ischeck = CHECK_NO;
else if ( strncasecmp(T(t->text)+t->dle, "[x]", 3) == 0 )
ischeck = CHECK_YES;
if ( ischeck != CHECK_NOT ) {
__mkd_trim_line(t, 3);
p->flags |= GITHUB_CHECK;
if ( ischeck == CHECK_YES )
p->flags |= IS_CHECKED;
}
firstpara = 0;
}
#endif
/* even though we had to trim a long leader off this item, /* even though we had to trim a long leader off this item,
* the indent for trailing paragraphs is still 4... * the indent for trailing paragraphs is still 4...
*/ */
if (indent > 4) { if (indent > 4) {
indent = 4; indent = 4;
} }
if ( (q = skipempty(t->next)) == 0 ) { if ( (q = skipempty(t->next)) == 0 ) {
___mkd_freeLineRange(t,q); ___mkd_freeLineRange(t,q);
return 0; return 0;
skipping to change at line 968 skipping to change at line 992
{ {
switch (c) { switch (c) {
case '\'': case '\'':
case '"': return c; case '"': return c;
case '(': return ')'; case '(': return ')';
} }
return 0; return 0;
} }
/* /*
* eat lines for a markdown extra footnote
*/
static Line *
extrablock(Line *p)
{
Line *np;
while ( p && p->next ) {
np = p->next;
if ( np->dle < 4 && np->dle < S(np->text) ) {
p->next = 0;
return np;
}
__mkd_trim_line(np,4);
p = np;
}
return 0;
}
/*
* add a new (image or link) footnote to the footnote table * add a new (image or link) footnote to the footnote table
*/ */
static Line* static Line*
addfootnote(Line *p, MMIOT* f) addfootnote(Line *p, MMIOT* f)
{ {
int j, i; int j, i;
int c; int c;
Line *np = p->next; Line *np = p->next;
Footnote *foot = &EXPAND(f->footnotes->note); Footnote *foot = &EXPAND(f->footnotes->note);
CREATE(foot->tag); CREATE(foot->tag);
CREATE(foot->link); CREATE(foot->link);
CREATE(foot->title); CREATE(foot->title);
foot->text = 0;
foot->flags = foot->height = foot->width = 0; foot->flags = foot->height = foot->width = 0;
/* keep the footnote label */
for (j=i=p->dle+1; T(p->text)[j] != ']'; j++) for (j=i=p->dle+1; T(p->text)[j] != ']'; j++)
EXPAND(foot->tag) = T(p->text)[j]; EXPAND(foot->tag) = T(p->text)[j];
EXPAND(foot->tag) = 0; EXPAND(foot->tag) = 0;
S(foot->tag)--; S(foot->tag)--;
/* consume the closing ]: */
j = nextnonblank(p, j+2); j = nextnonblank(p, j+2);
if ( (f->flags & MKD_EXTRA_FOOTNOTE) && (T(foot->tag)[0] == '^') ) { if ( (f->flags & MKD_EXTRA_FOOTNOTE) && (T(foot->tag)[0] == '^') ) {
/* need to consume all lines until non-indented block? */ /* markdown extra footnote: All indented lines past this point;
while ( j < S(p->text) ) * the first line includes the footnote reference, so we need to
EXPAND(foot->title) = T(p->text)[j++]; * snip that out as we go.
goto skip_to_end; */
foot->flags |= EXTRA_FOOTNOTE;
__mkd_trim_line(p,j);
np = extrablock(p);
foot->text = compile(p, 0, f);
return np;
} }
while ( (j < S(p->text)) && !isspace(T(p->text)[j]) ) while ( (j < S(p->text)) && !isspace(T(p->text)[j]) )
EXPAND(foot->link) = T(p->text)[j++]; EXPAND(foot->link) = T(p->text)[j++];
EXPAND(foot->link) = 0; EXPAND(foot->link) = 0;
S(foot->link)--; S(foot->link)--;
j = nextnonblank(p,j); j = nextnonblank(p,j);
if ( T(p->text)[j] == '=' ) { if ( T(p->text)[j] == '=' ) {
sscanf(T(p->text)+j, "=%dx%d", &foot->width, &foot->height); sscanf(T(p->text)+j, "=%dx%d", &foot->width, &foot->height);
while ( (j < S(p->text)) && !isspace(T(p->text)[j]) ) j = nextblank(p, j);
++j;
j = nextnonblank(p,j); j = nextnonblank(p,j);
} }
if ( (j >= S(p->text)) && np && np->dle && tgood(T(np->text)[np->dle]) ) { if ( (j >= S(p->text)) && np && np->dle && tgood(T(np->text)[np->dle]) ) {
___mkd_freeLine(p); ___mkd_freeLine(p);
p = np; p = np;
np = p->next; np = p->next;
j = p->dle; j = p->dle;
} }
skipping to change at line 1036 skipping to change at line 1091
EXPAND(foot->title) = T(p->text)[j++]; EXPAND(foot->title) = T(p->text)[j++];
while ( S(foot->title) && T(foot->title)[S(foot->title)-1] != c ) while ( S(foot->title) && T(foot->title)[S(foot->title)-1] != c )
--S(foot->title); --S(foot->title);
if ( S(foot->title) ) /* skip trailing quote */ if ( S(foot->title) ) /* skip trailing quote */
--S(foot->title); --S(foot->title);
EXPAND(foot->title) = 0; EXPAND(foot->title) = 0;
--S(foot->title); --S(foot->title);
} }
skip_to_end:
___mkd_freeLine(p); ___mkd_freeLine(p);
return np; return np;
} }
/* /*
* allocate a paragraph header, link it to the * allocate a paragraph header, link it to the
* tail of the current document * tail of the current document
*/ */
static Paragraph * static Paragraph *
Pp(ParagraphRoot *d, Line *ptr, int typ) Pp(ParagraphRoot *d, Line *ptr, int typ)
skipping to change at line 1203 skipping to change at line 1257
ParagraphRoot d = { 0, 0 }; ParagraphRoot d = { 0, 0 };
Paragraph *p = 0; Paragraph *p = 0;
Line *r; Line *r;
int para = toplevel; int para = toplevel;
int blocks = 0; int blocks = 0;
int hdr_type, list_type, list_class, indent; int hdr_type, list_type, list_class, indent;
ptr = consume(ptr, &para); ptr = consume(ptr, &para);
while ( ptr ) { while ( ptr ) {
if ( iscode(ptr) ) { if ( iscode(ptr) ) {
p = Pp(&d, ptr, CODE); p = Pp(&d, ptr, CODE);
if ( f->flags & MKD_1_COMPAT) { if ( f->flags & MKD_1_COMPAT) {
/* HORRIBLE STANDARDS KLUDGE: the first line of every block /* HORRIBLE STANDARDS KLUDGE: the first line of every block
* has trailing whitespace trimmed off. * has trailing whitespace trimmed off.
*/ */
___mkd_tidy(&p->text->text); ___mkd_tidy(&p->text->text);
} }
 End of changes. 17 change blocks. 
15 lines changed or deleted 70 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)