Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions html/html.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<ins>");
bufput(ob, text->data, text->size);
BUFPUTSL(ob, "</ins>");
return 1;
}

static int
rndr_strikethrough(struct buf *ob, const struct buf *text, void *opaque)
{
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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,

Expand Down
8 changes: 6 additions & 2 deletions src/markdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/markdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);

Expand Down