From 866d6e034519c40512a80e93c283ead6ab8d3eca Mon Sep 17 00:00:00 2001 From: Jonathan Ye Date: Tue, 20 Nov 2012 16:14:41 +0800 Subject: [PATCH 1/2] fix compile error in VC++ 2008 --- src/markdown.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/markdown.c b/src/markdown.c index b78656e8..73748757 100644 --- a/src/markdown.c +++ b/src/markdown.c @@ -977,12 +977,12 @@ char_link(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t offset /* footnote link */ if (rndr->ext_flags & MKDEXT_FOOTNOTES && data[1] == '^') { - if (txt_e < 3) - goto cleanup; - struct buf id = { 0, 0, 0, 0 }; struct footnote_ref *fr; + if (txt_e < 3) + goto cleanup; + id.data = data + 2; id.size = txt_e - 2; @@ -2735,6 +2735,8 @@ sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, str struct buf *text; size_t beg, end; + int footnotes_enabled = md->ext_flags & MKDEXT_FOOTNOTES; + text = bufnew(64); if (!text) return; @@ -2745,8 +2747,6 @@ sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, str /* reset the references table */ memset(&md->refs, 0x0, REF_TABLE_SIZE * sizeof(void *)); - int footnotes_enabled = md->ext_flags & MKDEXT_FOOTNOTES; - /* reset the footnotes lists */ if (footnotes_enabled) { memset(&md->footnotes_found, 0x0, sizeof(md->footnotes_found)); From 523bf1340a112133ed2106198c8280f63eb7e100 Mon Sep 17 00:00:00 2001 From: Jonathan Ye Date: Tue, 20 Nov 2012 16:33:48 +0800 Subject: [PATCH 2/2] fix multi footnotes parse problem. for example: [^1]: footnote1 [^2]: footnote2 --- src/markdown.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/markdown.c b/src/markdown.c index 73748757..dca44aa4 100644 --- a/src/markdown.c +++ b/src/markdown.c @@ -2447,13 +2447,6 @@ is_footnote(const uint8_t *data, size_t beg, size_t end, size_t *last, struct fo i++; if (i >= end || data[i] != ':') return 0; i++; - while (i < end && data[i] == ' ') i++; - if (i < end && (data[i] == '\n' || data[i] == '\r')) { - i++; - if (i < end && data[i] == '\n' && data[i - 1] == '\r') i++; - } - while (i < end && data[i] == ' ') i++; - if (i >= end || data[i] == '\n' || data[i] == '\r') return 0; /* getting content buffer */ contents = bufnew(64); @@ -2483,10 +2476,11 @@ is_footnote(const uint8_t *data, size_t beg, size_t end, size_t *last, struct fo /* joining only indented stuff after empty lines; * note that now we only require 1 space of indentation * to continue, just like lists */ - if (in_empty && ind == 0) { - break; + if (ind == 0) { + if (start == id_end + 2 && data[start] == '\t') {} + else break; } - else if (in_empty) { + if (in_empty) { bufputc(contents, '\n'); }