Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow starting linenumbers from set value #19

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

akoreman
Copy link
Collaborator

@akoreman akoreman commented Feb 22, 2024

Description

For some use-cases, users might want to use code-view to display a snippet of a bigger file (e.g. in a documentation website for a software library or in something like a diff-view). For this use-case, it can be confusing if the line numbers shown in code-view don't match the corresponding line numbers in the bigger file.

This change adds a lineNumbersStart property to the API to set the number the line numbers start counting from. A different option to add this to the API could be to allow lineNumbers to be either a boolean or a number and, when set to a number, have the value of lineNumbers be the value that sets the starting point of the line numbers.

Screenshot 2024-02-22 at 16 57 58

This feature is similar to the data-start attribute in Prism.js, users migrating from prism to code-view might expect this behavior to be possible.

Visual regression tests in the PR actions are failing because this PR makes visual changes.

Related links, issue #, if available: n/a

How has this been tested?

  • unit tests are added for the new behavior
  • examples are added to the line numbers test page
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (d0f7309) to head (a8b082e).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #19   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines          318       319    +1     
  Branches        30        30           
=========================================
+ Hits           318       319    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant