github_flavoured.c (discount-2.2.4.tar.bz2) | : | github_flavoured.c (discount-2.2.6.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 33 | skipping to change at line 33 | |||
Document * | Document * | |||
gfm_populate(getc_func getc, void* ctx, int flags) | gfm_populate(getc_func getc, void* ctx, int flags) | |||
{ | { | |||
Cstring line; | Cstring line; | |||
Document *a = __mkd_new_Document(); | Document *a = __mkd_new_Document(); | |||
int c; | int c; | |||
int pandoc = 0; | int pandoc = 0; | |||
if ( !a ) return 0; | if ( !a ) return 0; | |||
a->tabstop = (flags & MKD_TABSTOP) ? 4 : TABSTOP; | a->tabstop = is_flag_set(flags, MKD_TABSTOP) ? 4 : TABSTOP; | |||
CREATE(line); | CREATE(line); | |||
while ( (c = (*getc)(ctx)) != EOF ) { | while ( (c = (*getc)(ctx)) != EOF ) { | |||
if ( c == '\n' ) { | if ( c == '\n' ) { | |||
if ( pandoc != EOF && pandoc < 3 ) { | if ( pandoc != EOF && pandoc < 3 ) { | |||
if ( S(line) && (T(line)[0] == '%') ) | if ( S(line) && (T(line)[0] == '%') ) | |||
pandoc++; | pandoc++; | |||
else | else | |||
pandoc = EOF; | pandoc = EOF; | |||
skipping to change at line 62 | skipping to change at line 62 | |||
} | } | |||
else if ( isprint(c) || isspace(c) || (c & 0x80) ) | else if ( isprint(c) || isspace(c) || (c & 0x80) ) | |||
EXPAND(line) = c; | EXPAND(line) = c; | |||
} | } | |||
if ( S(line) ) | if ( S(line) ) | |||
__mkd_enqueue(a, &line); | __mkd_enqueue(a, &line); | |||
DELETE(line); | DELETE(line); | |||
if ( (pandoc == 3) && !(flags & (MKD_NOHEADER|MKD_STRICT)) ) { | if ( (pandoc == 3) && !(is_flag_set(flags, MKD_NOHEADER) | |||
|| is_flag_set(flags, MKD_STRICT)) ) { | ||||
/* the first three lines started with %, so we have a header. | /* the first three lines started with %, so we have a header. | |||
* clip the first three lines out of content and hang them | * clip the first three lines out of content and hang them | |||
* off header. | * off header. | |||
*/ | */ | |||
Line *headers = T(a->content); | Line *headers = T(a->content); | |||
a->title = headers; __mkd_trim_line(a->title, 1); | a->title = headers; __mkd_trim_line(a->title, 1); | |||
a->author= headers->next; __mkd_trim_line(a->author, 1); | a->author= headers->next; __mkd_trim_line(a->author, 1); | |||
a->date = headers->next->next; __mkd_trim_line(a->date, 1); | a->date = headers->next->next; __mkd_trim_line(a->date, 1); | |||
T(a->content) = headers->next->next->next; | T(a->content) = headers->next->next->next; | |||
} | } | |||
return a; | return a; | |||
} | } | |||
/* convert a block of text into a linked list | /* convert a block of text into a linked list | |||
*/ | */ | |||
Document * | Document * | |||
gfm_string(const char *buf, int len, DWORD flags) | gfm_string(const char *buf, int len, mkd_flag_t flags) | |||
{ | { | |||
struct string_stream about; | struct string_stream about; | |||
about.data = buf; | about.data = buf; | |||
about.size = len; | about.size = len; | |||
return gfm_populate((getc_func)__mkd_io_strget, &about, flags & INPUT_MASK); | return gfm_populate((getc_func)__mkd_io_strget, &about, flags & INPUT_MASK); | |||
} | } | |||
/* convert a file into a linked list | /* convert a file into a linked list | |||
*/ | */ | |||
Document * | Document * | |||
gfm_in(FILE *f, DWORD flags) | gfm_in(FILE *f, mkd_flag_t flags) | |||
{ | { | |||
return gfm_populate((getc_func)fgetc, f, flags & INPUT_MASK); | return gfm_populate((getc_func)fgetc, f, flags & INPUT_MASK); | |||
} | } | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 5 lines changed or added |