public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Switching footnotes to sidenotes?
@ 2015-09-08 14:49 Nick Moffitt
       [not found] ` <20150908144925.GG6870-iTLVOByc1N8@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Moffitt @ 2015-09-08 14:49 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

I've been looking into using http://www.daveliepmann.com/tufte-css/ for
my pandoc-generated files, but the way it spits out footnotes is really
more of an "endnotes" kind of thing.  If you look at the source for
Liepmann's page, you'll see that he uses a `<span class="sidenote">` and
the footnote markers become labels instead of links.

I think I may be resigned to writing my own pandoc filter, but I wanted
to make sure I wasn't missing some obvious other way to do this.  Has
someone else written such a filter?  Am I missing a pandoc-ready version
of the CSS that hacks a little harder?

I'd like to avoid spewing raw <span> tags into my markdown, if possible.
In particular, it gets awkward around things like bulleted lists.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Switching footnotes to sidenotes?
       [not found] ` <20150908144925.GG6870-iTLVOByc1N8@public.gmane.org>
@ 2015-09-08 16:15   ` Nick Moffitt
       [not found]     ` <20150908161528.GA12048-iTLVOByc1N8@public.gmane.org>
  2015-10-25 21:37   ` Guillaume Paumier
  1 sibling, 1 reply; 5+ messages in thread
From: Nick Moffitt @ 2015-09-08 16:15 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Nick Moffitt:
> I've been looking into using http://www.daveliepmann.com/tufte-css/
> for my pandoc-generated files, but the way it spits out footnotes is
> really more of an "endnotes" kind of thing.  If you look at the source
> for Liepmann's page, you'll see that he uses a `<span
> class="sidenote">` and the footnote markers become labels instead of
> links.

The quick answer for getting something like this is:

```python

def sidenote(key, value, format, meta):
    if key == 'Note':
        return [Span(attributes({'class': 'marginnote'}), x['c'])
                for x in value]

```

Alas, the AST does not store any identifier used to indicate the label
used, so to use the sidenote class I'd need to also figure out how to
inject a <label> tag (raw inline?)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Switching footnotes to sidenotes?
       [not found]     ` <20150908161528.GA12048-iTLVOByc1N8@public.gmane.org>
@ 2015-09-08 17:47       ` BPJ
       [not found]         ` <CADAJKhDK-OfQhTanZxgm4LDiiJQ1LzXURzNpOBMKfPdm+7-p-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: BPJ @ 2015-09-08 17:47 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw, Nick Moffitt

[-- Attachment #1: Type: text/plain, Size: 3018 bytes --]

Yes Raw<whatever> is usually the way to go to get something not provided by
the Pandoc document model. You may need to write a filter which inserts
different raw material depending on the output format.

Note that rather than stringifying existing elements and including them in
a Raw* it is often a good idea to insert a raw inline/block
with `\command{` before the original content and another with `}` after it.
That way the original formatting is preserved. Perhaps not with '\label'
but generally. I have a generic filter which looks for spans/divs with
classes of the form `cmd_<commandname>` and inserts raw inline/block latex
elements `\<commandname>{` and `}` at the beginning and end of the
span/div, and analogously for `env_<environmentname>` classes. That's
generally more efficient than writing/running a filter for each
commandname. I have to define new commands for complex things but that
makes no difference efficiencywise (as in "XeTeX is slow anyway").

tisdag 8 september 2015 skrev Nick Moffitt <nick-iTLVOByc1N8@public.gmane.org>:

>
> Nick Moffitt:
> > I've been looking into using http://www.daveliepmann.com/tufte-css/
> > for my pandoc-generated files, but the way it spits out footnotes is
> > really more of an "endnotes" kind of thing.  If you look at the source
> > for Liepmann's page, you'll see that he uses a `<span
> > class="sidenote">` and the footnote markers become labels instead of
> > links.
>
> The quick answer for getting something like this is:
>
> ```python
>
> def sidenote(key, value, format, meta):
>     if key == 'Note':
>         return [Span(attributes({'class': 'marginnote'}), x['c'])
>                 for x in value]
>
> ```
>
> Alas, the AST does not store any identifier used to indicate the label
> used, so to use the sidenote class I'd need to also figure out how to
> inject a <label> tag (raw inline?)
>
> --
> You received this message because you are subscribed to the Google Groups
"pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
https://groups.google.com/d/msgid/pandoc-discuss/20150908161528.GA12048%40zork.net
.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhDK-OfQhTanZxgm4LDiiJQ1LzXURzNpOBMKfPdm%2B7-p-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 4322 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Switching footnotes to sidenotes?
       [not found]         ` <CADAJKhDK-OfQhTanZxgm4LDiiJQ1LzXURzNpOBMKfPdm+7-p-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-09-08 18:07           ` Nick Moffitt
  0 siblings, 0 replies; 5+ messages in thread
From: Nick Moffitt @ 2015-09-08 18:07 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 829 bytes --]

BPJ:
> Yes Raw<whatever> is usually the way to go to get something not
> provided by the Pandoc document model. You may need to write a filter
> which inserts different raw material depending on the output format.

Yes, I think I've managed it (attached).  Hacky, but it works.


-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20150908180743.GB14223%40zork.net.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: sidenote.py --]
[-- Type: text/x-python, Size: 770 bytes --]

#!/usr/bin/env python

"""
Pandoc filter to convert footnotes to sidenotes for Tufte CSS.
"""

from pandocfilters import toJSONFilter, Span, attributes, RawInline


counter = 0


def sidenote(key, value, format, meta):
    global counter  # yeah yeah I know.
    if key == 'Note':
        counter += 1
        label = RawInline('html', '''
<label for="sn-{}" class="margin-toggle sidenote-number"></label>
<input type="checkbox" id="sn-{}" class="margin-toggle"/>'''.format(counter,
                                                                    counter))
        sidenote = [label]
        sidenote.extend(
            [Span(attributes({'class': 'sidenote'}), x['c']) for x in value])
        return sidenote

if __name__ == "__main__":
    toJSONFilter(sidenote)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Switching footnotes to sidenotes?
       [not found] ` <20150908144925.GG6870-iTLVOByc1N8@public.gmane.org>
  2015-09-08 16:15   ` Nick Moffitt
@ 2015-10-25 21:37   ` Guillaume Paumier
  1 sibling, 0 replies; 5+ messages in thread
From: Guillaume Paumier @ 2015-10-25 21:37 UTC (permalink / raw)
  To: pandoc-discuss; +Cc: nick-iTLVOByc1N8


[-- Attachment #1.1: Type: text/plain, Size: 1871 bytes --]

Greetings,

Le mardi 8 septembre 2015 07:49:28 UTC-7, Nick Moffitt a écrit :
>
> I've been looking into using http://www.daveliepmann.com/tufte-css/ for 
> my pandoc-generated files, but the way it spits out footnotes is really 
> more of an "endnotes" kind of thing.  If you look at the source for 
> Liepmann's page, you'll see that he uses a `<span class="sidenote">` and 
> the footnote markers become labels instead of links. 
>
> I think I may be resigned to writing my own pandoc filter, but I wanted 
> to make sure I wasn't missing some obvious other way to do this.  Has 
> someone else written such a filter?  Am I missing a pandoc-ready version 
> of the CSS that hacks a little harder? 
>

I'm a little late to the party, but I experimented with this using a custom 
writer, rather than a filter:
https://github.com/gpaumier/gp2/commit/6f132a4cc684df807b0f3b6ad9d337e073bc3260

This was inspired by this comment:
https://github.com/edwardtufte/tufte-css/issues/21#issuecomment-128897315

In the end, I'm not sure I'm going to go the Tufte-CSS route, because I 
don't like that it uses spans for side notes and margin notes (which can 
contain paragraphs, figures etc.), but if you don't have moral quandaries 
about that, that custom writer may help.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/9deb5d92-39df-40f6-856c-109e39346332%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 2943 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-25 21:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-08 14:49 Switching footnotes to sidenotes? Nick Moffitt
     [not found] ` <20150908144925.GG6870-iTLVOByc1N8@public.gmane.org>
2015-09-08 16:15   ` Nick Moffitt
     [not found]     ` <20150908161528.GA12048-iTLVOByc1N8@public.gmane.org>
2015-09-08 17:47       ` BPJ
     [not found]         ` <CADAJKhDK-OfQhTanZxgm4LDiiJQ1LzXURzNpOBMKfPdm+7-p-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-08 18:07           ` Nick Moffitt
2015-10-25 21:37   ` Guillaume Paumier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).