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

[gatsby-plugin-embed-snippet] Support for embedding specific line numbers #21906

Closed
danpoq opened this issue Mar 2, 2020 · 3 comments
Closed

Comments

@danpoq
Copy link
Contributor

danpoq commented Mar 2, 2020

Summary

DocFX has a feature in its inclusion of code snippets that allows you to specify a line number or line range to embed specific lines of an external file.

It works the same way as GitHub file URLs, where ending the URL with #L10 or #L10-L20 will link to those lines.

I propose that gatsby-remark-embed-snippet should also support this behaviour by trimming the embedded files using the agreed upon #Lx and #Lx-Ly syntax.

Basic example

Add logic to the embed-snippet plugin to add support for including a snippet by line number or line range. Basically:

If the embed: line contains #L, grab the hash and remove it from the path (it's not a valid file path). Then use the requested lines in the hash to split the embedded file and display only the requested line number(s).

Motivation

The use case for this feature is building tutorial pages which give the user only the parts of the code example that they require at the current step.

I am migrating from DocFX and am trying to get 100% feature parity to be able to convince my company to move to Gatsby.

@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Mar 23, 2020
@github-actions
Copy link

github-actions bot commented Apr 2, 2020

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜

@github-actions github-actions bot closed this as completed Apr 2, 2020
@wardpeet wardpeet added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Apr 2, 2020
@wardpeet wardpeet reopened this Apr 2, 2020
@danpoq
Copy link
Contributor Author

danpoq commented Apr 10, 2020

Closed by #21907

@danpoq danpoq closed this as completed Apr 10, 2020
@danpoq danpoq removed the not stale label Apr 10, 2020
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

No branches or pull requests

3 participants