Skip to content

Commit

Permalink
Bring in plaintext strikethrough rendering fix (#74)
Browse files Browse the repository at this point in the history
* introduce failing test

* bring in latest cmark-gfm
  • Loading branch information
Ashe Connor authored Aug 10, 2018
1 parent ed2a9e7 commit 0b92e55
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ext/commonmarker/cmark-upstream
6 changes: 3 additions & 3 deletions ext/commonmarker/cmark_version.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef CMARK_VERSION_H
#define CMARK_VERSION_H

#define CMARK_VERSION ((0 << 24) | (28 << 16) | (3 << 8) | 12)
#define CMARK_VERSION_STRING "0.28.3.gfm.12"
#define CMARK_GFM_VERSION 12
#define CMARK_VERSION ((0 << 24) | (28 << 16) | (3 << 8) | 14)
#define CMARK_VERSION_STRING "0.28.3.gfm.14"
#define CMARK_GFM_VERSION 14

#endif
7 changes: 7 additions & 0 deletions ext/commonmarker/strikethrough.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ static void html_render(cmark_syntax_extension *extension,
}
}

static void plaintext_render(cmark_syntax_extension *extension,
cmark_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
renderer->out(renderer, node, "~", false, LITERAL);
}

cmark_syntax_extension *create_strikethrough_extension(void) {
cmark_syntax_extension *ext = cmark_syntax_extension_new("strikethrough");
cmark_llist *special_chars = NULL;
Expand All @@ -143,6 +149,7 @@ cmark_syntax_extension *create_strikethrough_extension(void) {
cmark_syntax_extension_set_latex_render_func(ext, latex_render);
cmark_syntax_extension_set_man_render_func(ext, man_render);
cmark_syntax_extension_set_html_render_func(ext, html_render);
cmark_syntax_extension_set_plaintext_render_func(ext, plaintext_render);
CMARK_NODE_STRIKETHROUGH = cmark_syntax_extension_add_node(1);

cmark_syntax_extension_set_match_inline_func(ext, match);
Expand Down
16 changes: 16 additions & 0 deletions test/test_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,20 @@ def test_table_prefer_style_attributes
fff | ggg | hhh | iii | jjj
MD
end

def test_plaintext
assert_equal(<<-HTML, CommonMarker.render_doc(<<-MD, :DEFAULT, %i[table strikethrough]).to_plaintext)
Hello ~there~.
| a |
| --- |
| b |
HTML
Hello ~~there~~.
| a |
| - |
| b |
MD
end
end

0 comments on commit 0b92e55

Please sign in to comment.