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

Add information about line numbering and line highlighting into documentation #32

Closed
wants to merge 2 commits into from

Conversation

talatkuyuk
Copy link
Contributor

@talatkuyuk talatkuyuk commented Jun 24, 2024

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

It is about for adding information about line numbering and line highlighting into documentation, which is done via rehype plugin rehype-highlight-code-lines. An example has been provided as well.

Fixes #29

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jun 24, 2024

This comment has been minimized.

@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Jul 12, 2024
@wooorm
Copy link
Member

wooorm commented Jul 12, 2024

Hi again Talat, thanks for your patience, I was a bit busy. I took your take as inspiration and wrote a short example in the existing example section! Thank you.

Also: looks like the email you git commit with isn’t connected to your GitHub account; I think they describe how to add an email address here: https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-email-preferences/setting-your-commit-email-address.

Or, perhaps, you accidentally added literal quotes locally in Git itself? 🤔

Finally, for your plugin:
your plugin supports a markdown syntax on how to highlight particular lines. That’s very useful!
But, these rehype plugins can also be used with plain HTML. So, I suggest to also support HTML attributes.
I’ve done something similar with rehype-twoslash recently, which accepts ```js twoslash but also class="language-js twoslash".

@talatkuyuk
Copy link
Contributor Author

talatkuyuk commented Jan 31, 2025

Also: looks like the email you git commit with isn’t connected to your GitHub account; Or, perhaps, you accidentally added literal quotes locally in Git itself? 🤔

You're right! I just realized that the commit author was set as “talatkuyuk” instead of talatkuyuk. Somehow, my keyboard used curly quotes while setting up Git locally, which ended up playing a joke on me. 😄 I was wondering why my commits and work weren’t showing up on the GitHub chart. Turns out, there was no connection due to incorrect local settings! :) Ohhh..

I corrected the commit name across all my projects and force-pushed the changes, rewriting the entire Git history—which took some time. I used the git filter-repo utility for the task.

Thank you warning me. 👍

@talatkuyuk
Copy link
Contributor Author

Rehype plugins can also be used with plain HTML. So, I suggest to also support HTML attributes.

You suggested that I add support for highlighting/numbering code lines using HTML attributes as well. I got it, and will try to do it.

For clarification, rehype-highlight-code-lines currently supports markdown syntax something like:

```js {1,3} showLineNumbers
console.log("Highlight this line");
console.log("Don't highlight this");
console.log("Highlight this too");
```

And, your suggestion is that rehype-highlight-code-lines allow an equivalent in pure HTML as well, such as:

<pre><code class="language-js" data-highlight-lines="1,3" data-show-line-numbers>
console.log("Highlight this line");
console.log("Don't highlight this");
console.log("Highlight this too");
</code></pre>

@wooorm
Copy link
Member

wooorm commented Feb 1, 2025

Awesome, cool! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done
Development

Successfully merging this pull request may close these issues.

Add support for line numbers
2 participants