-
-
Notifications
You must be signed in to change notification settings - Fork 982
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
add new feature: pagebreak for every format #1626
Conversation
based on lua-filter pagebreak readme https://github.com/pandoc/lua-filters/blob/master/pagebreak/README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. If you don't have further changes to make, I'll merge it. Thank you!
BTW, this will definitely be a good topic for the R Markdown Cookbook.
Thanks ! I just need to see if we promote
I agree. I was waiting to know if it would be accepted. I wrote the vignette with the book in mind. I'll add it in the book: Lua Topic (rstudio/rmarkdown-cookbook#170) + this new features as example. |
@cderv this is perfect! Just another suggestion, maybe the vignette could mention https://github.com/crsh/rmdfiltr |
😮 I did not know that one ! Nice ! We can definitely add mention to this in the vignette and in the book. |
I'd be more than happy to collect additional filters in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks everyone!
…dd other filters in the future (#1626)
This PR implements a new feature that will close #1610 and which is based on pandoc lua filter called pagebreak.
With this PR, it is now possible to use
\newpage
or\pagebreak
in any Rmarkdown and will create a pagebreak in the correct output syntax forword_document()
,html_document()
andodt_document()
. Forpdf_document
, those are already working latex command.Currently, a vignette in this PR explains how it works.
This specific pagebreak lua filter is not from me and was taken from https://github.com/pandoc/lua-filters/tree/master/pagebreak. The file can be used as is (with a PR I made today there).
To use this file, the copyright notice is left in the file and I added the two authors for copyright in DESCRIPTION - I think this is how it should be done.
Also, lua filters are already used in pagedown but not in rmarkdown. This PR adds a small helper to include some lua filters with Rmarkdown. I think lua filter could be a really could way to add more features for several formats easily, and maybe also in other framework (I think of bookdown for example). I did not export the function and reuse a similar one from pagedown, adding a test for pandoc 2.0 as it works for 2+.
This means this pagebreak feature only work with pandoc >= 2.0. With earlier version, nothing change.
As I said above, I documented in a vignette. I don't know if this is the best place. If this feature makes it to rmarkdown, a part in a future book could also be an idea to documented it (and maybe makes the documentation shorter in the package).
Finally, I added some tests but only for
html
andlatex
output. I am not sure how to test word or odt easily. So basically, this test that the filter is correctly found and activated.This PR is now functional. However, some things we could change on how it works:
Currently, the lua filter is always activated if pandoc >= 2.0, even if not used. This has no impact on the result but may have impact on rendering time for big documents. (just a guess)
I hesitated on making it optional.
If you think it is better to make it optional, I see two ways:
toc
). It could bepagebreak: false
by default andpagebreak: true
to activate. As a user, I am not sure this is a good idea. If I wrote\pagebreak
or\newpage
, I would like it to work without doing nothing.citeproc_required()
and detect if a keyword is used in theinput_lines
. This would be detecting\newpage
or\pagebreak
when output is html, word or odt, then activating the filter only if found.I added the filter also for
pdf_document()
but as it has no impact, I believe it could be remove frompdf_document()
in rmarkdown, even if the lua filter can handle tex output.I hope you'll find this as interesting as I am.
This change is