Allow set based indexing for including lines from files
Open
Nobody has claimed this yet.
C-enhancement
- Dominant language
- Rust
- Stars
- 22.2k
- Forks
- 1.9k
- PR merge metrics
- PR metrics pending
Description
Problem
Given
Lines 304 to 305 of file foo can be included in code-block using the following syntax
{{#include foo:304:305}}
Issue
The above format is less terse when including multiple lines from the same file e.g.,
{{#include foo:304:305}}
{{#include foo:307}}
{{#include foo:309:318}}
Proposed Solution
Use , to specify multiple ranges at once e.g.,
{{#include foo:304:305,307,309:318}}
Use +/- to perform operations on ranges e.g.,
{{#include foo:304:318-[306,308]}}
In BNF form, this translates to:
arg := index | '::' index | index ':' | index ':' index
factor := '-' | '+'
bracketedList := '[' argList ']'
argList := arg | arg ',' argList | rangeExpression
rangeExpression := bracketedList factor bracketedList | arg factor bracketedList | arg factor arg
Notes
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin by locating the existing parser and tests for #include line ranges; the issue names no file or test path. Use the examples and BNF as the behavior to verify, including comma-separated ranges and +/- expressions. Done means the proposed syntax works for the shown cases and existing range behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100