forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Add syntax highlighting to code tags #2015
Closed
Plastikmensch
wants to merge
21
commits into
glitch-soc:main
from
Plastikmensch:add-syntax-highlighting
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ab8134a
Add highlight.js
Plastikmensch 20d6a54
Allow title attribute on code tags
Plastikmensch ffe0fa9
Add new util function
Plastikmensch 186e1ca
Add syntax highlighting to code blocks
Plastikmensch b1f97e6
Update advanced_text_formatter spec
Plastikmensch e3dc1d7
Use github-light for highlighting in light theme
Plastikmensch c12b06d
Fix remote toots not being highlighted
Plastikmensch 9894b6e
Remove file extension from import
Plastikmensch 049fe35
Replace RegEx with DOM
Plastikmensch e8ed035
Replace line breaks with DOM instead of RegEx
Plastikmensch af981da
Use data attribute instead of title
Plastikmensch 9cef121
Change wording of test
Plastikmensch 4b821e9
Remove data attribute when invalid
Plastikmensch bb5fd53
Add highlight.scss to stylelint ignore
Plastikmensch ba60ac4
Import stylesheets from module
Plastikmensch e4b84e6
Only allow codelang data attribute
Plastikmensch c5cf5a0
Apply style change
Plastikmensch 29b3229
Use Sanitize to strip invalid codelang attributes
Plastikmensch 9c48ed6
Update highlight.js to 11.8.0
Plastikmensch 1949a53
Fix lint issues
Plastikmensch f881d8d
Fix import order
Plastikmensch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ | |
@import 'rtl'; | ||
@import 'dashboard'; | ||
@import 'rich_text'; | ||
@import 'node_modules/highlight.js/scss/github-dark'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@import 'mastodon-light/variables'; | ||
@import 'index'; | ||
@import 'mastodon-light/diff'; | ||
@import 'node_modules/highlight.js/scss/github'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't suppose
language
is guaranteed to be escaped?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.
I'm not sure what kind of escaping would be suitable here.
At least in my testing I couldn't cause any unexpected behaviour, nevertheless I agree accepting user input as is is never a good idea.
Ideally, I would check here if
language
is a valid code language, but this would create overhead.What I could do though is checking that
language
only contains allowed characters via regex:/^[a-zA-Z0-9.#+-]+$/