Skip to content

Fix off-by-one rendering of all highlighted lines in the docs! #4221

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

Merged
merged 1 commit into from
Apr 15, 2025

Conversation

nathan-contino
Copy link
Contributor

@nathan-contino nathan-contino commented Apr 14, 2025

All of the highlighted lines in the docs are rendered one line above where they ought to be. This PR fixes the issue.

A few examples:

There is probably a better way to do this -- for instance, I'm not convinced we need so much custom logic for code examples at all -- but this fix fixes the problem without changing all of the variables we use to configure code snippets, and without ripping out any internals like prism.js. Once I have a little more experience with our infra, I'll give simplifying the code-block handling a shot... but for now, this fixes a very visible issue in the docs.

For more information about why data-line-offset fixes this issue, see the prism.js line-highlight docs.

All of the highlighted lines in the docs are rendered one line above where they ought to be. This PR fixes the issue.

A few examples:

* https://docs.viam.com/tutorials/projects/helmet/
* https://docs.viam.com/operate/get-started/other-hardware/hello-world-module/#implement-the-api-methods (open the Go tab and look at the example in step 2; this example notably uses the first branch of the conditional logic, which sets an offset starting line)
* https://docs.viam.com/dev/reference/sdks/connectivity/ (all tabs)

There is probably a better way to do this -- for instance, I'm not convinced we need so much custom logic for code examples at all -- but this fix fixes the problem without changing all of the variables we use to configure code snippets, and without ripping out any internals like prism.js. Once I have a little more experience with our infra, I'll give simplifying the code-block handling a shot... but for now, this fixes a very visible issue in the docs.
Copy link

netlify bot commented Apr 14, 2025

Deploy Preview for viam-docs ready!

Name Link
🔨 Latest commit a51f6a5
🔍 Latest deploy log https://app.netlify.com/sites/viam-docs/deploys/67fd464431739a0008af710c
😎 Deploy Preview https://deploy-preview-4221--viam-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 36 (🔴 down 7 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (no change from production)
PWA: 70 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@viambot viambot added the safe to build This pull request is marked safe to build from a trusted zone label Apr 14, 2025
@npentrel npentrel self-requested a review April 14, 2025 20:44
Copy link
Collaborator

@npentrel npentrel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@nathan-contino nathan-contino merged commit 7b029cd into main Apr 15, 2025
14 checks passed
@nathan-contino nathan-contino deleted the fix-off-by-one-highlighted-lines branch April 15, 2025 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to build This pull request is marked safe to build from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants