From 179fa22dcb9035248917197542488590b504817a Mon Sep 17 00:00:00 2001 From: Alexandre Leray Date: Sun, 27 May 2012 15:08:57 +0200 Subject: [PATCH 1/2] Removed -Wl flag in MakeFile. It was not compiling. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index baca6875..fb268c99 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ libsundown.so: libsundown.so.1 ln -f -s $^ $@ libsundown.so.1: $(SUNDOWN_SRC) - $(CC) $(LDFLAGS) -shared -Wl $^ -o $@ + $(CC) $(LDFLAGS) -shared $^ -o $@ # executables From 5c1b5e879520da7eee4a994acc2a59b55c57b326 Mon Sep 17 00:00:00 2001 From: Alexandre Leray Date: Sun, 27 May 2012 15:27:50 +0200 Subject: [PATCH 2/2] Added a tag extensions. It can be used by enabling the MKDEXT_INS option like this (example/sundown.c): markdown = sd_markdown_new(MKDEXT_INS, 16, &callbacks, &options) then, after compilation the following command line: echo "++ins++" | ./sundown results in:

ins

--- html/html.c | 14 ++++++++++++++ src/markdown.c | 8 ++++++-- src/markdown.h | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/html/html.c b/html/html.c index 7f08ee8e..bc11d5de 100755 --- a/html/html.c +++ b/html/html.c @@ -169,6 +169,18 @@ rndr_codespan(struct buf *ob, const struct buf *text, void *opaque) return 1; } +static int +rndr_ins(struct buf *ob, const struct buf *text, void *opaque) +{ + if (!text || !text->size) + return 0; + + BUFPUTSL(ob, ""); + bufput(ob, text->data, text->size); + BUFPUTSL(ob, ""); + return 1; +} + static int rndr_strikethrough(struct buf *ob, const struct buf *text, void *opaque) { @@ -564,6 +576,7 @@ sdhtml_toc_renderer(struct sd_callbacks *callbacks, struct html_renderopt *optio toc_link, NULL, rndr_triple_emphasis, + rndr_ins, rndr_strikethrough, rndr_superscript, @@ -605,6 +618,7 @@ sdhtml_renderer(struct sd_callbacks *callbacks, struct html_renderopt *options, rndr_link, rndr_raw_html, rndr_triple_emphasis, + rndr_ins, rndr_strikethrough, rndr_superscript, diff --git a/src/markdown.c b/src/markdown.c index 260483d6..e43fc693 100644 --- a/src/markdown.c +++ b/src/markdown.c @@ -526,6 +526,7 @@ parse_emph2(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t size int r; render_method = (c == '~') ? rndr->cb.strikethrough : rndr->cb.double_emphasis; + render_method = (c == '+') ? rndr->cb.ins : render_method; if (!render_method) return 0; @@ -598,8 +599,9 @@ char_emphasis(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t of if (size > 2 && data[1] != c) { /* whitespace cannot follow an opening emphasis; + * ins only takes two characters '++' * strikethrough only takes two characters '~~' */ - if (c == '~' || _isspace(data[1]) || (ret = parse_emph1(ob, rndr, data + 1, size - 1, c)) == 0) + if (c == '+' || c == '~' || _isspace(data[1]) || (ret = parse_emph1(ob, rndr, data + 1, size - 1, c)) == 0) return 0; return ret + 1; @@ -613,7 +615,7 @@ char_emphasis(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t of } if (size > 4 && data[1] == c && data[2] == c && data[3] != c) { - if (c == '~' || _isspace(data[3]) || (ret = parse_emph3(ob, rndr, data + 3, size - 3, c)) == 0) + if (c == '+' || c == '~' || _isspace(data[3]) || (ret = parse_emph3(ob, rndr, data + 3, size - 3, c)) == 0) return 0; return ret + 3; @@ -2415,6 +2417,8 @@ sd_markdown_new( md->active_char['_'] = MD_CHAR_EMPHASIS; if (extensions & MKDEXT_STRIKETHROUGH) md->active_char['~'] = MD_CHAR_EMPHASIS; + if (extensions & MKDEXT_INS) + md->active_char['+'] = MD_CHAR_EMPHASIS; } if (md->cb.codespan) diff --git a/src/markdown.h b/src/markdown.h index 6f6553ec..936aa399 100644 --- a/src/markdown.h +++ b/src/markdown.h @@ -56,6 +56,7 @@ enum mkd_extensions { MKDEXT_FENCED_CODE = (1 << 2), MKDEXT_AUTOLINK = (1 << 3), MKDEXT_STRIKETHROUGH = (1 << 4), + MKDEXT_INS = (1 << 5), MKDEXT_SPACE_HEADERS = (1 << 6), MKDEXT_SUPERSCRIPT = (1 << 7), MKDEXT_LAX_SPACING = (1 << 8), @@ -87,6 +88,7 @@ struct sd_callbacks { int (*link)(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *content, void *opaque); int (*raw_html_tag)(struct buf *ob, const struct buf *tag, void *opaque); int (*triple_emphasis)(struct buf *ob, const struct buf *text, void *opaque); + int (*ins)(struct buf *ob, const struct buf *text, void *opaque); int (*strikethrough)(struct buf *ob, const struct buf *text, void *opaque); int (*superscript)(struct buf *ob, const struct buf *text, void *opaque);