From 0b92e557379e708a39c2b1d63bcc0c7991a53a63 Mon Sep 17 00:00:00 2001 From: Ashe Connor Date: Fri, 10 Aug 2018 10:22:01 +1000 Subject: [PATCH] Bring in plaintext strikethrough rendering fix (#74) * introduce failing test * bring in latest cmark-gfm --- ext/commonmarker/cmark-upstream | 2 +- ext/commonmarker/cmark_version.h | 6 +++--- ext/commonmarker/strikethrough.c | 7 +++++++ test/test_extensions.rb | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ext/commonmarker/cmark-upstream b/ext/commonmarker/cmark-upstream index 4057e9ff..1b1f90db 160000 --- a/ext/commonmarker/cmark-upstream +++ b/ext/commonmarker/cmark-upstream @@ -1 +1 @@ -Subproject commit 4057e9ff6415f058800ec39deb0968b690369114 +Subproject commit 1b1f90db662af5d7c4b4bca8f0c1aa9b4c3b2d18 diff --git a/ext/commonmarker/cmark_version.h b/ext/commonmarker/cmark_version.h index 9511e389..c1b4b985 100644 --- a/ext/commonmarker/cmark_version.h +++ b/ext/commonmarker/cmark_version.h @@ -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 diff --git a/ext/commonmarker/strikethrough.c b/ext/commonmarker/strikethrough.c index 0d941809..b1356693 100644 --- a/ext/commonmarker/strikethrough.c +++ b/ext/commonmarker/strikethrough.c @@ -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; @@ -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); diff --git a/test/test_extensions.rb b/test/test_extensions.rb index 685f4a2c..1c6b4bf8 100644 --- a/test/test_extensions.rb +++ b/test/test_extensions.rb @@ -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