Propose: Improve `highlight` API
See original GitHub issueFor those finding there way here from the deprecation warning it’s easy to upgrade your code:
// The old API:
highlight(language, code, ignore_illegals, continuation) {
// The new API take an options object literal:
highlight(code, { language, ignoreIllegals}) {
So to upgrade your code:
// before
html = highlight("vbscript","your code goes here", true)
// after
html = highlight("your code goes here", {language: "vbscript", ignoreIllegals: true })
IE, just switch the order of the arguments and pass language
and ignoreIllegals
in the options object now.
Advantages:
- target of the verb [highlight] is now the first argument, which makes more sense, such as
format(drive)
,highlight(code)
- no need to remember order of the arguments
- we can still support the old API for legacy (ie, non-breaking change)
- fewer arguments are generally better (easier to understand, now at the call site you always see the names of the optional arguments, etc)
Checklist:
- new
highlight
API as shown above - <del>
highlightAuto
->highlight(code)
</del> - <del>
highlightAuto
is deprecated</del> -
highlightBlock
->highlightElement
#3003 -
highlightBlock
-> deprecated #3003 -
fixMarkup
-> deprecated, will be removed with v11 -
initHighlightingOnLoad
->highlightAll()
-
initHighlighting
->highlightAll()
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:18 (12 by maintainers)
Top Results From Across the Web
Highlight text on the web with the CSS Custom Highlighting API
Styling ranges of text on the web is very useful, but has historically been a complicated thing to do.The new CSS Custom Highlight...
Read more >CSS Custom Highlight API Module Level 1
The Custom Highlight API provides a programmatic way of adding and removing highlights that do not affect the underlying DOM structure, but ...
Read more >Semantic Highlight Guide | Visual Studio Code Extension API
A guide to syntax highlighting. ... Themes can opt in to use semantic tokens to improve and refine the syntax highlighting from grammars....
Read more >Intent to Ship: Custom Highlight API
The custom highlight API provides a way for web developers to style ... It seems better to get the API / behavior to...
Read more >Development Highlights from Around the Web
From Developer.net: WinFX, the Longhorn API, is the API for Windows in Longhorn. ... From W3Schools.com: This tutorial is about how to develop...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We may look into something like https://github.com/dougwilson/nodejs-depd#readme in the future. I’ll split your comment out into a new issue. I like the idea of per-callsite warnings, not just singular logging.
Would it maybe make sense to throttle logging the same deprecation messages? We’re using highlight.js as a dependency of another dependency so can’t directly update the deprecated code. The console is simply drowned in the exactly same deprecation message. Once would suffice, IMO, so we could alert the dependency to change it.