[v2] `$language` for highlighting languages embedded in other languages · Issue #3923 · PrismJS/prism · GitHub
More Web Proxy on the site http://driver.im/
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
We often have cases where languages are embedded in other languages.
The way we handle it now is variations of this (example from the coffeescript definition):
I think I'm now convinced that a $language special key is a good approach for this. The snippet above would look like this:
'script': {$language: 'javascript',},
Sure, it loses some of the elegance of treating everything as just a set of tokens but the thing is, they're not the same. There are loading implications for languages that don't exist for grammars defined inline, so this needs to be explicit somehow.
Additionally, it naturally provides an extension point for dynamic languages. I'm thinking a regex group and/or a function to transform the matched value.
There could also be an $optional: boolean value.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
We often have cases where languages are embedded in other languages.
The way we handle it now is variations of this (example from the
coffeescript
definition):This has several issues:
I think I'm now convinced that a
$language
special key is a good approach for this. The snippet above would look like this:Sure, it loses some of the elegance of treating everything as just a set of tokens but the thing is, they're not the same. There are loading implications for languages that don't exist for grammars defined inline, so this needs to be explicit somehow.
Additionally, it naturally provides an extension point for dynamic languages. I'm thinking a regex group and/or a function to transform the matched value.
There could also be an
$optional: boolean
value.The text was updated successfully, but these errors were encountered: