-
Notifications
You must be signed in to change notification settings - Fork 922
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
[Feature request] Code Import single lines #1355
Comments
I don't think the first case is needed, why do you need to import one single line from other files instead of direct writing that? You can use include feature with |
@Mister-Hope The use case for single-line import is that we have many different short samples to display to the user. We have them defined in runnable scripts where we display individual steps for the user to follow. This way, the code we test and the code the user uses are the same. Many of those steps are just one line of code. Please consider at least single line imports if possible. |
Tbh, the first one does have workaround, didn't it? Anyway contribution welcome, I don't think any disadvantages to support it. |
yes you can use a range that has the same line number |
We are closing this as we support Supporting both |
Oh wait, I read again your original request, it seems you want something like:
Code region is better than setting with lines, as the file content may change through time, you can use it with https://plugin-md-enhance.vuejs.press/guide/include.html as an workaround. The include plugin has highest priority (even before code blocks), so you can probably use: ```js
<!-- @include: ./foo.js{1} -->
<!-- @include: ./foo.js{2-4} -->
<!-- @include: ./foo.js#part1 -->
``` If the code block is indented, you still need to ensure that the comment is at the start of the line: ```js
<!-- @include: ./foo.js{1} -->
``` |
I do not think we need to support |
Thank you @Mister-Hope, I like the @include option since it allows for code highlighting separate from the import and the snippet feature is nice. I did not find the individual line support you mention to work: <!-- @include: ./foo.js{1} -->
<!-- @include: ./foo.js{2-4} -->
<!-- @include: ./foo.js#part1 -->
|
CC @meteorlxy |
You can report issues in vuepress-theme-hope repo. |
I created a ticket to track @include here: vuepress-theme-hope/vuepress-theme-hope#3855 |
Clear and concise description of the problem
Allow the same code line selection for imports as for highlighting. This will make adding instructions from runnable files easier since there may be many different lines in a bash script, for instance, that are needed to run a test but not needed to be displayed to the user.
Will render:
@[code{1-1}](../foo.js)
Doesn't render:
@[code{1}](../foo.js)
Doesn't render:
@[code{2,4}](../foo.js)
Suggested solution
You could add the same code line selection for highlighting lines as for imported code blocks.
Alternative
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: