-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't highlight # which does not start an attribute in rustdoc #43918
Conversation
See the docs for |
I would actually be a bit more strict on the check: "if the character after |
Hi @mystor! friendly ping to keep this on your radar! Wdyt of @GuillaumeGomez's suggestion? |
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. |
@GuillaumeGomez Wouldn't this just take out the attribute highlighting altogether? Or are you wanting to highlight |
No, it's fine as is. |
Cool! This looks good, thanks for the PR! @bors r+ |
📌 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