Skip to content

Propose: Improve highlight API #2277

@joshgoebel

Description

@joshgoebel

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    discuss/proposeProposal for a new feature/directionenhancementAn enhancement or new featureparser

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy