tidy up README

main
Melody Horn 2020-10-05 05:39:24 -06:00
parent 33fb649a36
commit 7a365baaaa
2 changed files with 6 additions and 13 deletions

View File

@ -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

View File

@ -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());
}