Support lists and stylings in more places for rustc --explain#126994
Support lists and stylings in more places for rustc --explain#126994bors merged 1 commit intorust-lang:masterfrom
rustc --explain#126994Conversation
|
rustbot has assigned @compiler-errors. Use |
tgross35
left a comment
There was a problem hiding this comment.
Thanks! Couple small suggestions
| /// Find first line that isn't empty or doesn't start with whitespace, that will | ||
| /// be our contents |
There was a problem hiding this comment.
Did you mean to update rather than remove?
There was a problem hiding this comment.
Meant to remove it since the function name is clear, the previous comment confused me a bit
| _ if let Some(strong @ (b"**" | b"__")) = loop_buf.get(..2) => { | ||
| parse_simple_pat(loop_buf, strong, strong, Po::None, MdTree::Strong) | ||
| } | ||
| (_, Newline | Whitespace) if loop_buf.starts_with(STG) => { | ||
| parse_simple_pat(loop_buf, STG, STG, Po::None, MdTree::Strong) | ||
| _ if let Some(emph @ (b"*" | b"_")) = loop_buf.get(..1) => { | ||
| parse_simple_pat(loop_buf, emph, emph, Po::None, MdTree::Emphasis) | ||
| } | ||
| (_, Newline | Whitespace) if loop_buf.starts_with(STK) => { | ||
| _ if loop_buf.starts_with(STK) => { | ||
| parse_simple_pat(loop_buf, STK, STK, Po::None, MdTree::Strikethrough) | ||
| } | ||
| (_, Newline | Whitespace) if loop_buf.starts_with(ANC_S) => { | ||
| _ if loop_buf.starts_with(ANC_S) => { |
There was a problem hiding this comment.
The comment, code, and */**/~~ changes look correct, but _/__ and <...> anchors need the preceding whitespace so snake case doesn't turn into italics (gh agrees with commonmark here):
foo*bar*foobarfoo**bar**foobarfoo_bar_foo_bar_foo__bar__foo__bar__foo~~bar~foobarfoo`bar`foobarfoo<www.docs.rs>foo<www.docs.rs>
There was a problem hiding this comment.
My impression was it's going for concise over correct hence the hand rolled markdown parser, there's a bunch of other stuff like (_foo_) should italicise but not _foo _bar or foo* bar*. As far as I can tell these do not occur in the error code docs though, so the question is how much do we want to support?
There was a problem hiding this comment.
Yeah, it was intended to be pretty simple and just hopefully never receive bad markdown 😆.
Adding Boundary to Prev and then setting it with something like x.is_ascii_punctuation() && ~[b'_', b'*', b'~].contains(&x) might be slightly more accurate to match Newline | Whitespace | Boundary. No need for you to do that here though, I'll probably play around with it a bit in a followup.
There was a problem hiding this comment.
A punctuation boundary sounds good, should I still make the #126994 (comment) change or leave it to you when you implement that?
If it ever will support nested formatting then just x.is_ascii_punctuation() is closer I think, since ___foo__ bar_ is valid as foo bar
There was a problem hiding this comment.
Up to you, I'll follow up if you prefer not to make the chance here :)
There was a problem hiding this comment.
Made the change since you would've had to unmerge the */_ arms either way
|
There's also a stdout test in markdown/tests/input.md if you want to verify the result (should work with --bless) |
1526233 to
5824ab1
Compare
|
@rustbot ready |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#125886 (Migrate run make issue 15460) - rust-lang#126898 (Migrate `run-make/link-framework` to `rmake.rs`) - rust-lang#126994 (Support lists and stylings in more places for `rustc --explain`) - rust-lang#127990 (Migrate `lto-linkage-used-attr`, `no-duplicate-libs` and `pgo-gen-no-imp-symbols` `run-make` tests to rmake) - rust-lang#128060 (Fix inclusion of `wasm-component-ld` in dist artifacts) - rust-lang#128082 (Note closure captures when reporting cast to fn ptr failed) - rust-lang#128098 (make it possible to disable download-rustc if it's incompatible) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#126994 - Alexendoo:explain-markdown, r=tgross35 Support lists and stylings in more places for `rustc --explain` Adds support for `*foo*`, stylings not immediately following whitespace e.g. ``(`Foo`)`` and lists starting with whitespace: ```md * previously supported ``` ```md * now also supported ``` These are fairly common in the existing error docs, some before/after examples: ### E0460   ### E0059  
Adds support for
*foo*, stylings not immediately following whitespace e.g.(`Foo`)and lists starting with whitespace:* previously supported* now also supportedThese are fairly common in the existing error docs, some before/after examples:
E0460
E0059