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

New feature - Experimental support for footnotes #21

Merged
merged 4 commits into from
Oct 30, 2018

Conversation

RLesur
Copy link
Collaborator

@RLesur RLesur commented Oct 26, 2018

The CSS Generated Content for Paged Media Module WD specifies a footnote value for the CSS float property. For now, Paged.js does not support this feature.

The aim of this PR is to introduce an experimental support for footnotes. It is experimental because it relies on a hack. Fortunately, it works well with Chrome and Firefox.

The PR has two parts.

  1. A Pandoc filter that inserts the footnotes contents in spans as described in example 7 of the GCPMD WD. This filter uses the blocks_to_inlines lua function that was recently exposed in Pandoc 2.2.3.

  2. A Paged.js hook. As far as I have tested, it works well. The idea behind this hook is to enclose each footnote span in a right-floating handler with 100% width before the chunker defines the pages layout.
    Here's an example:
    fnhandler
    With this handler, we keep a sufficient room for the footnotes on each page.
    After the chunker has finished its job, the hook builds a footnote area, inserts the footnotes in this area, and finally removes the handlers from the flow.
    I've tested different handlers, and the best results I have obtained is with p handlers.

I have to admit that this hook is very dirty but this is the only trick I've found and it seems intuitive to me.
I hope you will like it!

@RLesur RLesur requested a review from yihui October 26, 2018 16:25
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.

This is amazing! Thanks!

I have to admit that I don't fully understand the PR but the hack sounds reasonable to me. I just have one minor suggestion: how about changing the field name notes-as-footnotes to paged-footnotes? Note is a Pandoc concept, and I'm afraid average users don't understand it.

BTW, sometimes two footnotes won't work in RStudio Viewer, e.g.,

image

but as you said, they work well in Chrome, so this is no big deal to me.

@yihui yihui merged commit 66170f8 into rstudio:master Oct 30, 2018
@RLesur
Copy link
Collaborator Author

RLesur commented Oct 30, 2018

Glad you like this PR!
I've changed the field name.

The paged.js dev team told me they had similar ideas for footnotes. They will write a post soon.

About the RStudio Viewer, paged.js never worked for me in the viewer (I've updated to RStudio desktop Ubuntu 1.2.1070 today to check again). I got this kind of trouble when the room was insufficient (then footnotes overflow outside the page area). But if the same html file works in Chrome, I have no idea (maybe a too old version of chromium in RStudio 1.2?).
If you want to test, you can comment on these lines to see where the handlers are positioned.

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