Uh oh!
There was an error while loading. Please reload this page.
Don't highlight # which does not start an attribute in rustdoc - #43918
Conversation
mystor
commented
Aug 17, 2017
See the docs for |
QuietMisdreavus
commented
Aug 17, 2017
I would actually be a bit more strict on the check: "if the character after |
carols10cents
commented
Aug 28, 2017
Hi @mystor! friendly ping to keep this on your radar! Wdyt of @GuillaumeGomez's suggestion? |
mystor
commented
Aug 28, 2017
Sorry! I have been very busy over the last week-or-so due to travel for RustConf and then the subsequent catching up on work, so this patch slipped my mind. I don't think I fully understand what @GuillaumeGomez is suggesting. From what I can tell, the test referenced by @QuietMisdreavus was testing hiding a line from rustdoc output with the Namely, currently the following happens: The reason why this change affects this test was because when we read a non-escaped # character in the code highlighter we began an attribute, whether or not it was syntactically the start of an attribute. You can actually see that in the expected test output. That output was expected to produce partial HTML output, as it never parses a With this change, none of these lines would be indented, as none of them form a valid attribute. A line like: would be parsed as an attribute, and would have a complete attribute span tag around it. |
QuietMisdreavus
commented
Aug 28, 2017
@GuillaumeGomez Wouldn't this just take out the attribute highlighting altogether? Or are you wanting to highlight |
GuillaumeGomez
commented
Aug 29, 2017
No, it's fine as is. |
QuietMisdreavus
commented
Aug 29, 2017
Cool! This looks good, thanks for the PR! @bors r+ |
bors
commented
Aug 29, 2017
📌 Commit 2f19383 has been approved by |
…avus Don't highlight # which does not start an attribute in rustdoc Currently when we highlight some macros for rustdoc (e.g. `quote!` from https://github.com/dtolnay/quote), we get really bad syntax highlighting, because we assume that every token between a `#` character and the next `]` in the source must be an attribute. This patch improves that highlighting behavior to instead only highlight after finding the `[` token after the `#` token. (NOTE: I've only run this patch against https://github.com/nrc/rustdoc-highlight so if it doesn't build on travis that's why - I don't have a recent rustc build on this laptop) I'm guessing r? @steveklabnik
…avus Don't highlight # which does not start an attribute in rustdoc Currently when we highlight some macros for rustdoc (e.g. `quote!` from https://github.com/dtolnay/quote), we get really bad syntax highlighting, because we assume that every token between a `#` character and the next `]` in the source must be an attribute. This patch improves that highlighting behavior to instead only highlight after finding the `[` token after the `#` token. (NOTE: I've only run this patch against https://github.com/nrc/rustdoc-highlight so if it doesn't build on travis that's why - I don't have a recent rustc build on this laptop) I'm guessing r? @steveklabnik
Currently when we highlight some macros for rustdoc (e.g.
quote!from https://github.com/dtolnay/quote), we get really bad syntax highlighting, because we assume that every token between a#character and the next]in the source must be an attribute.This patch improves that highlighting behavior to instead only highlight after finding the
[token after the#token.(NOTE: I've only run this patch against https://github.com/nrc/rustdoc-highlight so if it doesn't build on travis that's why - I don't have a recent rustc build on this laptop)
I'm guessing r? @steveklabnik