question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Propose: Improve `highlight` API

See original GitHub issue

For 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:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:18 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
joshgoebelcommented, Mar 23, 2021

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.

2reactions
mihkeleidastcommented, Mar 23, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found