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

Allow --reference-location to affect HTML output #7461

Merged
merged 1 commit into from
Sep 10, 2021

Conversation

bitonic
Copy link
Contributor

@bitonic bitonic commented Jul 26, 2021

This works similarly to the markdown writer, but with special care
taken to skipping section divs with what regards to the block level.

The change also takes care to not modify the output if EndOfDocument
is used.

I implemented this to implement side notes without JavaScript -- see https://mazzo.li/posts/value-speculation.html for an example.

@bitonic bitonic force-pushed the block-notes-html-writer branch from 2d9d74b to 9ee0449 Compare July 26, 2021 10:05
@jgm jgm changed the title Support EndOfBlock and EndOfSection in HTML writer Allow --reference-location to affect HTML output Jul 30, 2021
@jgm
Copy link
Owner

jgm commented Jul 30, 2021

Current docs for this option:

--reference-location=block|section|document

: Specify whether footnotes (and references, if reference-links is
set) are placed at the end of the current (top-level) block, the
current section, or the document. The default is
document. Currently only affects the markdown writer.

The proposal is to allow this to affect footnotes in the HTML writer as well.

@bitonic bitonic force-pushed the block-notes-html-writer branch from 9ee0449 to 655bb70 Compare August 2, 2021 11:00
@bitonic
Copy link
Contributor Author

bitonic commented Aug 2, 2021

@jgm I've updated the manual. Let me know if anything else is needed.

@jgm
Copy link
Owner

jgm commented Aug 16, 2021

This looks good to me.

Question:

  • What happens when you use --section-divs with notes at end of section (or block)? Do the notes get inside the section div or do they come after it? Which behavior makes more sense? There is no test of this behavior.
  • That's especially important because in EPUB and some slide show outputs we implicitly use section divs. At least some informal testing should be done to see how this feature affects HTML slide show formats (revealjs, slidy) and epub.
  • Probably it should be documented in the manual that it affects these formats, too (assuming it does).

@bitonic
Copy link
Contributor Author

bitonic commented Aug 18, 2021

@jgm they would be outside the section block (right after the section). I do not know what makes more sense, but if you advise I'll change the behavior (if different from what's already implemented) and add the tests.

@jgm
Copy link
Owner

jgm commented Aug 18, 2021

I think either of these structures could make sense:

<section>
contents
<div>footnotes<ldiv>
</section>

or

<section>
contents
</section>
<div>
footnotes
</div>

I'm not sure which is better. In any case this should be a tested case.

This works similarly to the markdown writer, but with special care
taken to skipping section divs with what regards to the block level.

The change also takes care to not modify the output if `EndOfDocument`
is used.
@bitonic bitonic force-pushed the block-notes-html-writer branch from 655bb70 to 5db0a59 Compare August 19, 2021 09:29
@bitonic
Copy link
Contributor Author

bitonic commented Aug 19, 2021

@jgm I've added the test.

@jgm
Copy link
Owner

jgm commented Aug 19, 2021

Great. Can you explain why it is important to add the extra class e.g. footnote-end-of-document?

Also, have you tested, at least informally, with epubs and HTML slide shows (revealjs)?
I just want to make sure nothing strange happens with these cases.

@bitonic
Copy link
Contributor Author

bitonic commented Aug 20, 2021

@jgm My use case for those classes is that I want to style sidenotes (like in this article https://mazzo.li/posts/vectorized-atan2.html ) differently from footnotes (like in this article https://mazzo.li/posts/haskell-backprop-short.html ). I thought that class names would be the cleanest way to do that.

I have not tested epub or revealjs. If you tell me how to test (e.g. "modify this file in this way and check XYZ") I'll follow up.

@jgm
Copy link
Owner

jgm commented Aug 20, 2021

Just use --reference-location=block (or section) when you produce an epub. E.g. pandoc MANUAL.txt -o m.epub --reference-location=block. Then see how it looks in an epub reader, if you have one available.

Slide shows: create a markdown file with a few sections and some footnotes, then -t revealjs -s -o slides.html --reference-location=block etc.

@bitonic
Copy link
Contributor Author

bitonic commented Sep 8, 2021

I tried it and it seems to work fine. Here's the ebook with --reference-location=block:

image

It's similar with --reference-location=section. And with the slides:

image

@jgm
Copy link
Owner

jgm commented Sep 8, 2021

Have you tried slides with section? I'm particularly interested to see how that works.

@bitonic
Copy link
Contributor Author

bitonic commented Sep 8, 2021

I have, yes. For ebooks, it's at the end of the section, with the <hr>:

image

And this is with the slides -- it's in its own slide, much like if it were at the end of the document, but per-section:

image

I can think of several things that could be configurable:

  1. Resetting the footnote number at each section / block. This is probably the best default for books actually, but not for blog posts (my case).
  2. When the <hr> is placed.

But I think going forward with this is still an improvement.

@jgm jgm merged commit 99a4d1d into jgm:master Sep 10, 2021
@jgm
Copy link
Owner

jgm commented Sep 10, 2021

Agreed, thanks!

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

Successfully merging this pull request may close these issues.

2 participants