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

Ability to .numberLines starting at the actual line number in the file #9

Closed
tekknolagi opened this Issue Feb 2, 2018 · 9 comments

Comments

Projects
None yet
2 participants
@tekknolagi
Copy link

tekknolagi commented Feb 2, 2018

I'm not sure how would be the best way to do this, but it would be nice to be able to do something like:

    ```{.python .numberLines include=a.py snippet=plasma-equation}
     ```

    `plasma` is parametrized by two variables, `T_p` and `T_gamma`, because they
    appear as different constants in $(i)$ and $(ii)$:

    ```{.python .numberLines include=a.py snippet=exercises}
    ```

And have section 1 be lines 1-14, and section 2 be lines 15-30 -- instead of both starting at 1.

Otherwise, I love this filter! Thanks a bunch for writing it -- it has made my build system so much easier.

@owickstrom

This comment has been minimized.

Copy link
Owner

owickstrom commented Feb 2, 2018

That's a good suggestion! I usually don't use .numberLines, but I can see how that would be useful. The filter could detect numberLines being in the classes, and add the appropriate the startFrom attribute. The issue right now is that the snippet support is a bit hacky. If you want to have a stab at it, let me know!

@owickstrom

This comment has been minimized.

Copy link
Owner

owickstrom commented Feb 3, 2018

In fact, I'm giving this an hour of refactoring and trying it out. :)

@owickstrom

This comment has been minimized.

Copy link
Owner

owickstrom commented Feb 3, 2018

I'm working on this branch: https://github.com/owickstrom/pandoc-include-code/tree/snippet-line-numbers

So far I've only restricted the filter a bit, prohibiting the "range mode" and "snippet mode" of inclusion being used together. This is to make the program flow simpler before adding the startFrom support, which should be pretty straightforward now.

@owickstrom

This comment has been minimized.

Copy link
Owner

owickstrom commented Feb 3, 2018

I think this should be working now. Can you try installing from the branch I referred to? Thanks!

@tekknolagi

This comment has been minimized.

Copy link

tekknolagi commented Feb 3, 2018

Oh, wow. I'll take a look!

@tekknolagi

This comment has been minimized.

Copy link

tekknolagi commented Feb 3, 2018

I'm not sure I'm doing it right. I have {include=a-pdf.py .python .numberLines snippet=plasma-equation} and {.python .numberLines include=a-pdf.py snippet=bisect-rootfind}, but the line numbers for both snippets start at 1.

@tekknolagi

This comment has been minimized.

Copy link

tekknolagi commented Feb 4, 2018

Actually, this appears to work. I think I was looking at the wrong PDF. Awesome, thanks!

@owickstrom

This comment has been minimized.

Copy link
Owner

owickstrom commented Feb 4, 2018

Nice! I'll merge it then, and close the ticket. Also releasing a new version on Hackage.

@owickstrom

This comment has been minimized.

Copy link
Owner

owickstrom commented Feb 4, 2018

Closed by #10.

@owickstrom owickstrom closed this Feb 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment