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

Feature/codelines: Add support for numbering source code lines #51

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ljrk0
Copy link

@ljrk0 ljrk0 commented Dec 2, 2021

We add three more properties to the source element of the format

[source firstnumber=N, range="a-b,c-d", numbers=Bool]

The firstnumber determines how we remap the first actual input line.
By default this is the identity, that is, the first input line is set as
first line in the output: firstnumber=0.

The range specifies what parts of the code we want to print.
It depends on the value of firstnumber, that is, if we use firstnumber=10 and
range 11-14 it will print the 2st to 6nd (thx @aLuc) line of the input.
By default all lines are printed.

Finally, we can turn line numbers on or off.


This PR also changes the following:

  • compatibility with 8.8.x GHC (Base 4.13.x) which removes Monad.fail and introduces MonadFail
  • Add small testcase for the feature above
  • Add dependency on split>=0.2

Pipeline markup_secfault/pipelines/8981 passed.


Note on design: Since this simply prepends each line with a line number, highlighters will break. The "proper" way to fix this would probably to introduce an ItemLineNo or the like and writing a specific renderer for each target (LO + HTML). This works for now, though.

We add three more properties to the `source element` of the format

    [source firstnumber=N, range="a-b,c-d", numbers=Bool]

The `firstnumber` determines how we remap the first actual input line.
By default this is the identity, that is, the first input line is set as
first line in the output: `firstnumber=0`.

The range specifies what parts of the code we want to print.
It depends on the value of `firstnumber`, that is, if we use `firstnumber=10` and
`range 11-14` it will print the 2st to 6nd (thx @aLuc) line of the input.
By default all lines are printed.

Finally, we can turn line numbers on or off.
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.

2 participants