You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no formal way to indicate the language of computer code being marked up. Authors who wish to mark code elements with the language used, e.g. so that syntax highlighting scripts can use the right rules, can use the class attribute, e.g. by adding a class prefixed with "language-" to the element.
In my feeds, I see several classes being used for this purpose. Some specify the source language; others leave it implicit and use a library to guess.
I would like to preserve syntax highlighting where possible. For the ones with specified language like class="language-python", that could be passed through or rewritten, and I could use prismjs to highlight it.
The ones with unspecified language, I'm not sure what's the best approach but I'd like to do something.
Related work: simplepie/simplepie#717 provides a rewriter: "The new rename_attributes() methods enables it. The id and class attributes could be renamed to data-sanitized-id / data-sanitized-class" which can then be highlighted.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Some pages use
<code class="language-python">for syntax highlighting.The HTML living standard says:
In my feeds, I see several
classes being used for this purpose. Some specify the source language; others leave it implicit and use a library to guess.I would like to preserve syntax highlighting where possible. For the ones with specified language like
class="language-python", that could be passed through or rewritten, and I could use prismjs to highlight it.The ones with unspecified language, I'm not sure what's the best approach but I'd like to do something.
Related work: simplepie/simplepie#717 provides a rewriter: "The new
rename_attributes()methods enables it. Theidandclassattributes could be renamed todata-sanitized-id/data-sanitized-class" which can then be highlighted.Beta Was this translation helpful? Give feedback.
All reactions