-
Notifications
You must be signed in to change notification settings - Fork 643
When ammonia supports allowing only certain values for attributes, re-enable syntax highlighting #1008
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
Comments
Ammonia supports it now. |
I'd like to give this a shot. I'll let you know if I have any questions, thanks! |
- Added `code` tag and corresponding `class` attribute to the whitelisted `tag_attributes`. - Added `allowed-classes` for the `code` tag.
- Added `code` tag and corresponding `class` attribute to the whitelisted `tag_attributes`. - Added `allowed-classes` for the `code` tag.
Hi @carols10cents, quick question on this. I've pretty much wrapped up all the checklist items and had published a create locally with some syntax highlighting. That said, when I view the crate details the The URL it's trying to reach is Any thought's as to why the readme won't render? I'm suspecting possibly something with S3? |
Hi @treiff! Have you set up an s3 bucket locally, and put S3 config vars in your
If so, that means we can rule out s3 being the problem :) Where you have crates.io's code checked out, can you look in If that file does exist, then for some reason the server isn't seeing that. We can poke around in https://github.com/rust-lang/crates.io/blob/264dd1a53d5055693a44654aad006cb6cf68bf7f/src/local_upload.rs to see where it might be going wrong. If that file doesn't exist, then the readme HTML isn't getting created/"uploaded" on crate publish :( The rendering happens here, which calls this We'd need to try publishing more crate versions and narrowing down where that might be failing. Let me know if you'd like to jump on a screensharing session or something to figure this out in real time! |
Thanks @carols10cents ! Okay, sounds like we can rule out I didn't ever setup a local bucket and can confirm that when running
Also, interestingly I don't have the
So based on that, I guess we're looking into the readme HTML not getting created/uploaded when I published the crate. I can experiment bumping the version and republishing while adding some debugging statements within the related rendering and uploading functions. I'll have another look at this tonight and see how I make out, if i'm still having issues then I'd say setting up a screen share would be great! Thanks for your help! EDIT Got it! It helps if you add |
1070: Re-enable syntax highlighting. r=carols10cents Syntax highlighting seems to be working as intended now. I tested by publishing a create locally with a `README.md` including a couple of code samples, see below for a screenshot. Thanks for the help, and please let me know if you have any questions. Closes #1008 <img width="963" alt="screen shot 2017-09-21 at 1 07 28 pm" src="https://user-images.githubusercontent.com/5225538/30719271-d79969e8-9ef0-11e7-878d-064a62a4dbeb.png">
We had to disable classes on
code
tags because you could use arbitrary classes to do arbitrary things. So for now, syntax highlighting in readmes is disabled.I've filed an issue with Ammonia to request being able to specify allowed values for attributes (or at least classes); these are the classes that marky-markdown (used by npm) allows for their README rendering.
Instructions for implementing:
allowed_classes
field to the ammonia configuration struct with a hash map that contains the tag name"code"
and a value of aHashSet
containing all the languages we want to support highlighting prefixed bylanguage-
, solanguage-bash
,language-clike
, etc.markdown_to_html
with a code block that should get syntax highlighting, and assert that thecode
tag hasclass="language-whatever"
code
element, or other classes to other elements, and assert that they aren't in the rendered HTMLThe text was updated successfully, but these errors were encountered: