From 7a365baaaad8667e75a8844ded503fa63fae3921 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Mon, 5 Oct 2020 05:39:24 -0600 Subject: [PATCH] tidy up README --- README.md | 7 +++---- src/lib.rs | 12 +++--------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 314fb10..d3a6f44 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,9 @@ let gemtext = md2gemtext::convert("some markdown")?; - paragraphs get empty lines between them, because i think that looks better - block quotes get turned into quotes - lists get turned into lists ("loose lists" probably misbehave, nested lists *definitely* misbehave, numbering is not preserved) -- `code spans` turn into `\`code spans\`` -- *italics* turn into `_italics_` -- **bold** turns into `**bold**` -- ~~strikethrough~~ turns into `~~strikethrough~~` +- `` `markdown code spans` `` turn into `` `code spans` `` +- `*markdown italics*` turn into `_italics_` +- `**markdown bold**` turns into `**bold**` - `a [link](a://url) with context` turns into `a link with context` followed by `=> a://url link` - `an ![inline](a://url) image` turns into `an [image: inline] image` followed by `=> a://url [image: inline]` - if a link or image is its own paragraph, it becomes just the gemtext link, to not be redundant diff --git a/src/lib.rs b/src/lib.rs index f989cf0..7b3eabe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,9 +7,7 @@ use pulldown_cmark as md; /// Will panic if gemtext::render somehow produces invalid UTF-8. /// Since gemtext::render only produces valid UTF-8, this should never happen. pub fn convert(markdown_text: &str) -> String { - let mut options = md::Options::empty(); - options.insert(md::Options::ENABLE_STRIKETHROUGH); - let parser = md::Parser::new_ext(markdown_text, options); + let parser = md::Parser::new_ext(markdown_text, md::Options::empty()); let mut state = State::new(); for event in parser { @@ -28,7 +26,7 @@ pub fn convert(markdown_text: &str) -> String { md::Event::Start(md::Tag::TableCell) => unimplemented!("tables disabled"), md::Event::Start(md::Tag::Emphasis) => state.toggle_emphasis(), md::Event::Start(md::Tag::Strong) => state.toggle_strong(), - md::Event::Start(md::Tag::Strikethrough) => state.toggle_strikethrough(), + md::Event::Start(md::Tag::Strikethrough) => unimplemented!("strikethrough disabled"), md::Event::Start(md::Tag::Link(_, _, _)) => state.start_link(), md::Event::Start(md::Tag::Image(_, _, _)) => state.start_image(), @@ -45,7 +43,7 @@ pub fn convert(markdown_text: &str) -> String { md::Event::End(md::Tag::TableCell) => unimplemented!("tables disabled"), md::Event::End(md::Tag::Emphasis) => state.toggle_emphasis(), md::Event::End(md::Tag::Strong) => state.toggle_strong(), - md::Event::End(md::Tag::Strikethrough) => state.toggle_strikethrough(), + md::Event::End(md::Tag::Strikethrough) => unimplemented!("strikethrough disabled"), md::Event::End(md::Tag::Link(_, href, _)) => state.end_link(&href), md::Event::End(md::Tag::Image(_, src, _)) => state.end_image(&src), @@ -152,10 +150,6 @@ impl State { self.add_text("**"); } - fn toggle_strikethrough(&mut self) { - self.add_text("~~"); - } - fn start_link(&mut self) { self.link_text_stack.push(String::new()); }