Skip to content

Line highlight + line numbers uses different data attributes than line numbers alone #2714

@mAAdhaTTah

Description

@mAAdhaTTah

Information:

  • Prism version: Current
  • Plugins: Line Highlight + Line Numbers
  • Environment: Browser

Description
The Line Highlight plugin provides a data-line-offset attribute to start the count for line highlighting. However, if you're using it with the Line Numbers plugin, you have to provide a different attribute, data-start, and it's not the same value (you have to add 1 to it to get the same behavior as data-line-offset). Fortunately, it's not a huge deal to just include both on the HTML such that it's consistent regardless of the usage of Line Numbers, but it's a bit of a nuisance.

I'm inclined to think Line Numbers should also pick up data-line-offset, and maybe deprecate data-offset and remove that in v2.0. Alternatively, do nothing until v2.0 (I've got it working so I don't really need an upstream fix right now). But this felt like a minor inconsistency we should maybe address.

Example
This is visible if you look in the HTML for Line Highlight: https://prismjs.com/plugins/line-highlight/ The data attributes used are different.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions