Conversation
doc test cannot import cursive?
| //! ### Examples | ||
| //! | ||
| //! ```rust | ||
| //! use cursive::utils::markup::markdown::parse; |
There was a problem hiding this comment.
You might need extern crate cursive_core as cursive;, so it really just needs cursive_core, but it looks as cursive for users.
There was a problem hiding this comment.
Thanks - strange though that I cannot reproduce this locally. I'll try.
There was a problem hiding this comment.
You'll need to test with the markdown feature to run these
There was a problem hiding this comment.
Got it, now I can at least reproduce
There was a problem hiding this comment.
Can't seem to fix it... it cannot resolve CursiveExt, and when I remove it, the compiler can't find the run() method.
There was a problem hiding this comment.
CursiveExt is in a different crate, this might just not be possible. If it's ok I remove the example in the doc comment. I put an Markdown example into the examples folder.
There was a problem hiding this comment.
You also don't need to run the cursive app (or even make one), you can focus on parsing the markdown and building the TextView
|
I set the example in the doc comment to "ignore" - let me know if that's ok for you or of course feel free to change. |
|
Are there issues with this PR that prevent merge? |
|
Sorry, just have been very busy. Will hopefully have some time to get back in the coming weeks. |
| parser: pulldown_cmark::Parser<'a>, | ||
| /// In a code block, we keep newlines. | ||
| in_codeblock: bool, | ||
| /// Just added a new paragrap (\n\n) |
There was a problem hiding this comment.
| /// Just added a new paragrap (\n\n) | |
| /// Just added a new paragraph (\n\n) |
| self.stack.push(Style::from(Effect::Italic)); | ||
| /* Force a blank line before a blockquote */ | ||
| self.new_paragraph = true; | ||
| return Some(self.literal("\n\n> ")); |
There was a problem hiding this comment.
Should we still insert 2 newlines, even if this is the first thing in the document?
| * render an Autlink instead of an Inline link. | ||
| */ | ||
| return if title.is_empty() { | ||
| Some(self.literal(format!("<{dest_url}> "))) |
There was a problem hiding this comment.
Does it include a trailing space on purpose? If so, let's add a comment to make it clear.
| Span { | ||
| content: "<https://en.wikipedia.org> ", | ||
| width: "<https://en.wikipedia.org> ".width(), | ||
| attr: &style_none, | ||
| }, | ||
| Span { | ||
| content: "Link", | ||
| width: "Link".width(), | ||
| attr: &style_none, | ||
| }, |
There was a problem hiding this comment.
Does that mean [link](url) is rendered <url> link? Is that the intended behavior?
| Span { | ||
| content: "\n\n", | ||
| width: "\n\n".width(), | ||
| attr: &style_none, | ||
| }, | ||
| Span { | ||
| content: "\n\n", | ||
| width: "\n\n".width(), | ||
| attr: &style_none, | ||
| }, |
There was a problem hiding this comment.
4 new lines at the end of the doc? Maybe we could avoid that.
This PR contains Markdown usage samples in the documentation and the examples folder as well as some opinionated fixes to the Markdown handling itself:
>for easier soft line breaksThe parsing test has been changed to make it easier to find the failing span; it has also been extended to test the new behaviour.
pulldown-cmarkseems to have a bug that always returns an empty title for links. I updated it to version 0.13 in Cargo.toml, but this unfortunately did not change this.