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:

// beforehtml=highlight("vbscript","your code goes here",true)// afterhtml=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