-
Notifications
You must be signed in to change notification settings - Fork 259
Markdown fixes #817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Markdown fixes #817
Conversation
doc test cannot import cursive?
| //! ### Examples | ||
| //! | ||
| //! ```rust | ||
| //! use cursive::utils::markup::markdown::parse; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - strange though that I cannot reproduce this locally. I'll try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to test with the markdown feature to run these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, now I can at least reproduce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.