diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-08-22 11:50:42 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-08-22 11:50:42 +0200 |
commit | 351c69644bdbdf52c95e322904273657892920b5 (patch) | |
tree | 114a93ff760b522232f9f7290bc6f632b7250095 /src/compiler.rs | |
parent | 5e6829c2fb79c2b7f59e38f924e2b2900c52b5d5 (diff) | |
download | markdown-rs-351c69644bdbdf52c95e322904273657892920b5.tar.gz markdown-rs-351c69644bdbdf52c95e322904273657892920b5.tar.bz2 markdown-rs-351c69644bdbdf52c95e322904273657892920b5.zip |
Add support for GFM strikethrough
Diffstat (limited to 'src/compiler.rs')
-rw-r--r-- | src/compiler.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/compiler.rs b/src/compiler.rs index 2e13294..abf35c8 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -326,6 +326,7 @@ fn enter(context: &mut CompileContext) { Name::DefinitionDestinationString => on_enter_definition_destination_string(context), Name::Emphasis => on_enter_emphasis(context), Name::Frontmatter => on_enter_frontmatter(context), + Name::GfmStrikethrough => on_enter_gfm_strikethrough(context), Name::HtmlFlow => on_enter_html_flow(context), Name::HtmlText => on_enter_html_text(context), Name::Image => on_enter_image(context), @@ -369,6 +370,7 @@ fn exit(context: &mut CompileContext) { Name::DefinitionTitleString => on_exit_definition_title_string(context), Name::Emphasis => on_exit_emphasis(context), Name::Frontmatter => on_exit_frontmatter(context), + Name::GfmStrikethrough => on_exit_gfm_strikethrough(context), Name::GfmAutolinkLiteralProtocol => on_exit_gfm_autolink_literal_protocol(context), Name::GfmAutolinkLiteralWww => on_exit_gfm_autolink_literal_www(context), Name::GfmAutolinkLiteralEmail => on_exit_gfm_autolink_literal_email(context), @@ -467,6 +469,13 @@ fn on_enter_frontmatter(context: &mut CompileContext) { context.buffer(); } +/// Handle [`Enter`][Kind::Enter]:[`GfmStrikethrough`][Name::GfmStrikethrough]. +fn on_enter_gfm_strikethrough(context: &mut CompileContext) { + if !context.image_alt_inside { + context.push("<del>"); + } +} + /// Handle [`Enter`][Kind::Enter]:[`HtmlFlow`][Name::HtmlFlow]. fn on_enter_html_flow(context: &mut CompileContext) { context.line_ending_if_needed(); @@ -898,7 +907,7 @@ fn on_exit_definition_title_string(context: &mut CompileContext) { context.media_stack.last_mut().unwrap().title = Some(buf); } -/// Handle [`Exit`][Kind::Exit]:[`Strong`][Name::Emphasis]. +/// Handle [`Exit`][Kind::Exit]:[`Emphasis`][Name::Emphasis]. fn on_exit_emphasis(context: &mut CompileContext) { if !context.image_alt_inside { context.push("</em>"); @@ -942,6 +951,13 @@ fn on_exit_gfm_autolink_literal_email(context: &mut CompileContext) { on_exit_autolink_email(context); } +/// Handle [`Exit`][Kind::Exit]:[`GfmStrikethrough`][Name::GfmStrikethrough]. +fn on_exit_gfm_strikethrough(context: &mut CompileContext) { + if !context.image_alt_inside { + context.push("</del>"); + } +} + /// Handle [`Exit`][Kind::Exit]:[`HeadingAtx`][Name::HeadingAtx]. fn on_exit_heading_atx(context: &mut CompileContext) { let rank = context |