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

Create pagebreak from inline command too #1753

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Jan 1, 2020

This is a try to making some evolution to pandoc pagebreak lua filter in the aim of supporting inline command. Supporting this would fix #1752.

Initially the pagebreak lua filter was added from pandoc lua filters repo and support \newpage or \pagebreak command as its own paragraph. It would detect this paragraph and replace it with a RawBlock with the correct pagebreak syntax.

This PR is to see if we can detect one of the command in the paragraph itself and replace it by RawInline.

It seems to works well for docx output. This need to be thoroughly tested for other format.

This is a draft PR to share this and test it.

for docx only until further test
@atusy
Copy link
Collaborator

atusy commented Jan 14, 2020

Thanks a lot for the quick replies and PR! And excuse my slow action...

I upvote to activate RawInline insertion for limited formats because it sounds safer.
I also tried ODT, and it also adds a paragraph with a blank line.

Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to test all formats. I'm okay if it also works for HTML, LaTeX, and ODT. I can also merge the PR as is if you don't want or don't have time to test these formats. Thank you!

BTW, when you are done, please add a NEWS item.

@cderv
Copy link
Collaborator Author

cderv commented Jan 17, 2020

The PR was still draft as I was waiting for it to be tested by @atusy.
I will test further to undraft it so that it could be merged.

@cderv cderv marked this pull request as ready for review January 19, 2020 21:05
@cderv
Copy link
Collaborator Author

cderv commented Jan 19, 2020

I decided to leave it only for DOCX and ODT. The commands are tex anyway so it is ok for pdf.
For HTML, I am not sure adding a pagebreak (<div style="page-break-after: always;"></div>) inside a paragraph (<p><\p>) is something valid, even if browser seems to deal with it. So it will be ignored, and only work in HTML if \newpage or \pagebreak is in its own paragraph.

@atusy You can can know retest that everything is ok with this PR now it is done. Thanks !

@cderv
Copy link
Collaborator Author

cderv commented Feb 29, 2020

@atusy did you have a chance to look at it yet ?

@atusy
Copy link
Collaborator

atusy commented Apr 21, 2020

@cderv Oops, I'm sorry I have totally missed your mention.
I'll check it tomorrow morning.

@atusy
Copy link
Collaborator

atusy commented Apr 21, 2020

@cderv
As far as I tried, it adds a blank line at the beginning of the new page. Does it happen to you?
image

@cderv
Copy link
Collaborator Author

cderv commented Apr 22, 2020

Yes I got the same you're right.

I think come from the blank line in the Rmd file just after \newpage.

---
output:
  word_document:
    md_extensions: "+hard_line_breaks"
---

Newpage juste after this line.\newpage

This is on a new page with a blank line before

But if you don't put it, the docx file is corrupted 🤔

---
output:
  word_document:
    md_extensions: "+hard_line_breaks"
---

Newpage just after this line.\newpage
This is on a new page 

This need to be improved ... if it can. I am not sure of the openxml raw code to add here.

I'll look into it. Thank you for your test !

@cderv cderv marked this pull request as draft April 22, 2020 06:29
@yihui yihui force-pushed the master branch 2 times, most recently from 9ce8b28 to 2e8b846 Compare May 30, 2020 03:35
@cderv cderv self-assigned this Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

Breaking a page at the final line of the page adds a blank page in word_document
3 participants