Support GitHub-style line numbers in file name comments #471
CX330Blake
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
What version of Expressive Code are you using?
0.41.7
What is your idea?
Allow file name comments to include a GitHub-style line number suffix, such as:
// malloc/malloc.c#L1812When the line numbers plugin is enabled, Expressive Code could use
malloc/malloc.cas the frame title and1812as thestartLineNumber.Why is this feature necessary?
Expressive Code already supports both extracting file names from comments and configuring
startLineNumber, but they currently need to be specified separately.For code snippets taken from a larger source file, a source-location comment such as:
// malloc/malloc.c#L1812is more concise and keeps the source path and its original line number together.
This would be especially useful for documentation, reverse-engineering notes, source-code analysis, and other cases where snippets frequently refer back to specific locations in larger source files.
Ideally, the syntax could be equivalent to:
A range syntax such as
#L1812-L1825could potentially be considered later, but supporting a single starting line number would cover the main use case.Do you have examples of this feature in other projects?
GitHub uses a similar syntax for linking to specific source lines:
path/to/file.c#L1812and line ranges:
path/to/file.c#L1812-L1825The proposed syntax follows this familiar convention, but uses it as metadata for the displayed code snippet rather than as a URL fragment.
Participation
All reactions