Skip to content

Conversation

@HigherOrderLogic
Copy link
Contributor

πŸ”— Linked issue

N/A

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Add line to limit the amount of content copy over.

Im not sure if their name fit. I'll add docs after the args' name are finalized.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@pi0
Copy link
Member

pi0 commented Mar 16, 2024

Nice idea! How do you think to smplify to one lines arg:

  • lines=5:
  • lines=2:5
  • lines=:5

@HigherOrderLogic
Copy link
Contributor Author

Nice idea! How do you think to smplify to one lines arg:

  • lines=5:
  • lines=2:5
  • lines=:5

Yeah I think that's nicer.

And in case only the starting/ending line was defined, should we assume that the user want to copy from line 0/to the end?

@M-jerez
Copy link

M-jerez commented Oct 24, 2024

Waiting on this change to adopt this library, any estimates of when this will be published?

Also from personal experience using a similar library on this project https://github.com/MionKit/mion.
When importing source code, using line numbers gets very difficult to maintain and requires a review every time the src code gets updated.
it would be very interesting to be able to use a pattern delimiter as an argument so we can insert comments in the src code and extract the code between the delimiters

<!-- automd:file src="./example.ts" code dlimiter="//######myFunction" -->
<!-- /automd -->

This would extract anything between the delimiter // ######myFunction

// file ./example.ts

export const token = '1';

// ######myFunction
export function myFunction() {
   // code here
}
// ######myFunction

This example would only import the src code within the delimiters (myFunction).

willing to work on it after this PR get merged

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thnx!

@pi0 pi0 changed the title feat(file): add line args feat(file): support lines arg to limit content Feb 26, 2025
@pi0 pi0 merged commit 83ca13e into unjs:main Feb 26, 2025
@pi0
Copy link
Member

pi0 commented Feb 26, 2025

@M-jerez nice idea feel free to make a PR to support pattern matches. (also see #78 which is relevant. ideally we could have similar matcher syntax of browsers)

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.

3 participants