public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* EPUB toc for whole book?
@ 2012-04-27 21:09 David Snopek
  2012-04-28 10:21 ` niczero
  2012-10-26  5:16 ` Jason Morrison
  0 siblings, 2 replies; 10+ messages in thread
From: David Snopek @ 2012-04-27 21:09 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Hello!

Is there a way to get pandoc to generate a table of contents for EPUB for 
the whole book?  The --toc flag adds some quick links to the top of each 
chapter.

I can always write some sort of script to build my own table of contents, 
which might end up being the best way...  I really just want the EPUB to 
resemble the PDF that I'm generating, but I'm already customizing that some 
in a custom latex template.

Also, internal links between chapters don't appear to work in EPUB, but I'm 
not sure why.  I've seen internal links in other EPUBs work that look the 
same to me.  But I need to investigate that a little more before I can 
write a strong bug report.

I'm using pandoc version 1.9.2.

Thanks!
David.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pandoc-discuss/-/_1JFmMOMpJwJ.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/pandoc-discuss?hl=en.


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

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

* Re: EPUB toc for whole book?
  2012-04-27 21:09 EPUB toc for whole book? David Snopek
@ 2012-04-28 10:21 ` niczero
  2012-04-28 15:03   ` John MacFarlane
  2012-10-26  5:16 ` Jason Morrison
  1 sibling, 1 reply; 10+ messages in thread
From: niczero @ 2012-04-28 10:21 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Hi David,

I just joined this group for the very purpose of reporting that internal 
links between chapters don't work
(in .epub).  I haven't yet homed-in on why, but any internal links in one 
chapter
("see [Chapter 2](#ch2)") just get left as they are, so my .epub contains 
original fragments of md
where the links should be.  I tried moving the anchor away from the 
heading, so the .md has
"

# Chapter 2

<a name="ch2">.</a>

"
but that didn't help.  I'm now busy hunting for a workaround because each 
chapter is littered with
references to other chapters, there are 108 chapters, and having 
hyperlinking working is a big
part of why I'm building the ebook.

By the way, all my chapter headings appear in the book's toc, but they 
didn't originally.  In my
first draft some of my headings were non-unique.  When I fixed that, the 
toc appeared.  Are you
getting anything at all?  Originally I had just two entries, the title page 
and one 'chapter' for the
entire book.

When I say 'toc', I mean what I see when I click on 'contents' in the 
calibre ebook reader; it
doesn't appear within the body of the book.

Nic

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pandoc-discuss/-/W5QNn5fX_kwJ.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/pandoc-discuss?hl=en.


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

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

* Re: EPUB toc for whole book?
  2012-04-28 10:21 ` niczero
@ 2012-04-28 15:03   ` John MacFarlane
       [not found]     ` <20120428150316.GA405-nFAEphtLEs+AA6luYCgp0U1S2cYJDpTV9nwVQlTi/Pw@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: John MacFarlane @ 2012-04-28 15:03 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

+++ niczero [Apr 28 12 03:21 ]:
>    Hi David,
>    I just joined this group for the very purpose of reporting that
>    internal links between chapters don't work
>    (in .epub).  I haven't yet homed-in on why, but any internal links in
>    one chapter
>    ("see [Chapter 2](#ch2)") just get left as they are, so my .epub
>    contains original fragments of md
>    where the links should be.  I tried moving the anchor away from the
>    heading, so the .md has
>    "
>    # Chapter 2
>    <a name="ch2">.</a>
>    "
>    but that didn't help.  I'm now busy hunting for a workaround because
>    each chapter is littered with
>    references to other chapters, there are 108 chapters, and having
>    hyperlinking working is a big
>    part of why I'm building the ebook.

Internal links between chapters do work in pandoc 1.9.2 -- but
maybe not in the way you expect. You need to create
the links using the implicit identifiers described in
<http://johnmacfarlane.net/pandoc/README.html#header-identifiers-in-html-latex-and-context>.

So, to link to

    # Chapter 2

what you want is

    See [Chapter 2](#chapter-2)

Try that.  The reason the raw HTML anchors don't work is that the
epub gets split over several different files.

>    By the way, all my chapter headings appear in the book's toc, but they
>    didn't originally.  In my
>    first draft some of my headings were non-unique.  When I fixed that,
>    the toc appeared.  Are you
>    getting anything at all?  Originally I had just two entries, the title
>    page and one 'chapter' for the
>    entire book.
>    When I say 'toc', I mean what I see when I click on 'contents' in the
>    calibre ebook reader; it
>    doesn't appear within the body of the book.

Here's how pandoc currently handles these things.  Your document is
divided into chapters by level-1 headers.  If you only have one
level-1 header, you'll only get one chapter.  Your epub reader will
have a master table of contents showing these chapters.  This is
independent of whether you use --toc on the command line.  If you
use --toc, you'll *also* get a table of contents for each chapter,
at the beginning of that chapter.

It may be possible to change things so that the master table of
contents shows all the sections and subsections; I can look into
that if people are interested.  (It would be helpful if someone
gave me an example of an epub that worked that way, so I can see
how it's done.)

John


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

* Re: EPUB toc for whole book?
       [not found]     ` <20120428150316.GA405-nFAEphtLEs+AA6luYCgp0U1S2cYJDpTV9nwVQlTi/Pw@public.gmane.org>
@ 2012-04-29 13:49       ` niczero
  2012-04-29 16:31         ` John MacFarlane
  2012-05-07 22:13       ` David Snopek
  1 sibling, 1 reply; 10+ messages in thread
From: niczero @ 2012-04-29 13:49 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

It would be very useful if there was a --qualified_auto_links that made all
auto links be qualified with their chapter ref.

Currently

# Foo

## Bar

means the subheading gets an auto link of "bar", but I'd like the option
of having it as "foo_bar" so it's not impacted by the possibility of
another chapter having a (sub)heading of 'Bar'.

BTW, all my inter-chapter links are working now.  You were right, once
I'd upgraded to v1.9.2 the remaining problems were due to a buggy
markdown generator.

thanking you,
Nic

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pandoc-discuss/-/aR8CjDDB1CsJ.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/pandoc-discuss?hl=en.


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

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

* Re: EPUB toc for whole book?
  2012-04-29 13:49       ` niczero
@ 2012-04-29 16:31         ` John MacFarlane
       [not found]           ` <20120429163127.GC24897-nFAEphtLEs+AA6luYCgp0U1S2cYJDpTV9nwVQlTi/Pw@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: John MacFarlane @ 2012-04-29 16:31 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

+++ niczero [Apr 29 12 06:49 ]:
>    It would be very useful if there was a --qualified_auto_links that made
>    all
>    auto links be qualified with their chapter ref.
>    Currently
>    # Foo
>    ## Bar
>    means the subheading gets an auto link of "bar", but I'd like the
>    option
>    of having it as "foo_bar" so it's not impacted by the possibility of
>    another chapter having a (sub)heading of 'Bar'.

Pandoc won't produce duplicate identifiers.  If you have two
sections named "Bar", the first will get the id "bar", and the
second will get "bar-1", etc. See the README section on header
identifiers.

Also see the --id-prefix option.

John


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

* Re: EPUB toc for whole book?
       [not found]           ` <20120429163127.GC24897-nFAEphtLEs+AA6luYCgp0U1S2cYJDpTV9nwVQlTi/Pw@public.gmane.org>
@ 2012-04-29 21:18             ` niczero
  2012-04-29 21:37               ` John MacFarlane
  0 siblings, 1 reply; 10+ messages in thread
From: niczero @ 2012-04-29 21:18 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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



On Sunday, 29 April 2012 17:31:27 UTC+1, fiddlosopher wrote:
>
> +++ niczero [Apr 29 12 06:49 ]: 
> >    It would be very useful if there was a --qualified_auto_links that 
> made 
> >    all 
> >    auto links be qualified with their chapter ref. 
> >    Currently 
> >    # Foo 
> >    ## Bar 
> >    means the subheading gets an auto link of "bar", but I'd like the 
> >    option 
> >    of having it as "foo_bar" so it's not impacted by the possibility of 
> >    another chapter having a (sub)heading of 'Bar'. 
>
> Pandoc won't produce duplicate identifiers.  If you have two 
> sections named "Bar", the first will get the id "bar", and the 
> second will get "bar-1", etc. See the README section on header 
> identifiers. 
>
> Also see the --id-prefix option. 
>
> John 
>
----
The trouble is, my links are generated by code, and the code can't
easily predict whether it should link to bar-23 or bar-32; in fact it
currently doesn't know that 'bar' is wrong, so all links end up 
pointing at the first instance of 'bar'.  However it's natural to know
which chapter you're linking to, so having a predictable per-chapter
prefix would solve such problems.  This isn't just a problem with
generated links, it gets much worse if you're trying to do the job
manually.
My reading of '--id-prefix' suggests I can't use it per chapter and
still have inter-chapter links working.  Is that right?

Nic

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pandoc-discuss/-/S_X_WkCIJNAJ.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/pandoc-discuss?hl=en.


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

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

* Re: EPUB toc for whole book?
  2012-04-29 21:18             ` niczero
@ 2012-04-29 21:37               ` John MacFarlane
  0 siblings, 0 replies; 10+ messages in thread
From: John MacFarlane @ 2012-04-29 21:37 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

+++ niczero [Apr 29 12 14:18 ]:
>    On Sunday, 29 April 2012 17:31:27 UTC+1, fiddlosopher wrote:
> 
>      +++ niczero [Apr 29 12 06:49 ]:
>      >    It would be very useful if there was a --qualified_auto_links
>      that made
>      >    all
>      >    auto links be qualified with their chapter ref.
>      >    Currently
>      >    # Foo
>      >    ## Bar
>      >    means the subheading gets an auto link of "bar", but I'd like
>      the
>      >    option
>      >    of having it as "foo_bar" so it's not impacted by the
>      possibility of
>      >    another chapter having a (sub)heading of 'Bar'.
>      Pandoc won't produce duplicate identifiers.  If you have two
>      sections named "Bar", the first will get the id "bar", and the
>      second will get "bar-1", etc. See the README section on header
>      identifiers.
>      Also see the --id-prefix option.
>      John
> 
>    ----
>    The trouble is, my links are generated by code, and the code can't
>    easily predict whether it should link to bar-23 or bar-32; in fact it
>    currently doesn't know that 'bar' is wrong, so all links end up
>    pointing at the first instance of 'bar'.  However it's natural to know
>    which chapter you're linking to, so having a predictable per-chapter
>    prefix would solve such problems.  This isn't just a problem with
>    generated links, it gets much worse if you're trying to do the job
>    manually.
>    My reading of '--id-prefix' suggests I can't use it per chapter and
>    still have inter-chapter links working.  Is that right?
>    Nic

--id-prefix could work for you if you're calling pandoc on chapter-size
units.  You just need to make sure you include the prefix in the
identifiers you link to.  But this may not work for your purposes.



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

* Re: EPUB toc for whole book?
       [not found]     ` <20120428150316.GA405-nFAEphtLEs+AA6luYCgp0U1S2cYJDpTV9nwVQlTi/Pw@public.gmane.org>
  2012-04-29 13:49       ` niczero
@ 2012-05-07 22:13       ` David Snopek
  1 sibling, 0 replies; 10+ messages in thread
From: David Snopek @ 2012-05-07 22:13 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

2012/4/28 John MacFarlane <fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>
> Internal links between chapters do work in pandoc 1.9.2 -- but
> maybe not in the way you expect. You need to create
> the links using the implicit identifiers described in
> <http://johnmacfarlane.net/pandoc/README.html#header-identifiers-in-html-latex-and-context>.

Hey Guys!

Sorry for my late reply.  I just figured out what was wrong with the
internal links in EPUB.  For some reason, if you have any content in
the beginning that isn't in a chapter, internal links break.  For
example, the follow document will get a bad internal link in EPUB (but
not Latex or HTML):

% Test Book
% Test Author

Here is the forward.

# Chapter 1

I am chapter 1.

# Chapter 2

[See Chapter 1](#chapter-1)

I've also attached two files to demostrate in case this isn't clear
enough. Anyway, to fix in my case, I just made a chapter for the
forward material.  When I generate the latex, I have a preprocess step
that removes that chapter.

Best regards,
David.

-- 
Blog: http://www.linguatrek.com
Product: http://www.bibliobird.com

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

* Re: EPUB toc for whole book?
  2012-04-27 21:09 EPUB toc for whole book? David Snopek
  2012-04-28 10:21 ` niczero
@ 2012-10-26  5:16 ` Jason Morrison
       [not found]   ` <8cc0d96a-d364-4f03-a7bb-3b0b558fa857-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  1 sibling, 1 reply; 10+ messages in thread
From: Jason Morrison @ 2012-10-26  5:16 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

I've written a Ruby script that post-processes the EPUB file to inject a 
more full table of contents.  It includes h1 (chapter), h2 and h3 section 
levels.

I've pasted the script here: https://gist.github.com/e3158a3bba95b34ce9c0 - 
it's pretty hacky, but does the job for me.

My Haskell's not sufficiently up to snuff to include a patch to do this 
properly, and I'm not sure there's a way to iterate over chapters+sections 
in the templates (e.g. epub-titlepage.html).

Also, in another thread, John @jgm asked for an example of an EPUB with 
this kind of inline TOC, but I can't for the life of me find the thread/GH 
issue.  Anyway, I included and an example before/after contents.opf and the 
new contents.xhtml in the paste as well.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msg/pandoc-discuss/-/c5AU3gaLto4J.
For more options, visit https://groups.google.com/groups/opt_out.



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

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

* Re: EPUB toc for whole book?
       [not found]   ` <8cc0d96a-d364-4f03-a7bb-3b0b558fa857-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2012-10-26  6:17     ` fiddlosopher
  0 siblings, 0 replies; 10+ messages in thread
From: fiddlosopher @ 2012-10-26  6:17 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

You'll be pleased to know that the dev version of pandoc does create a more 
full table of contents, so after the next release your script shouldn't be 
needed.

On Thursday, October 25, 2012 10:16:34 PM UTC-7, Jason Morrison wrote:
>
> I've written a Ruby script that post-processes the EPUB file to inject a 
> more full table of contents.  It includes h1 (chapter), h2 and h3 section 
> levels.
>
> I've pasted the script here: https://gist.github.com/e3158a3bba95b34ce9c0- it's pretty hacky, but does the job for me.
>
> My Haskell's not sufficiently up to snuff to include a patch to do this 
> properly, and I'm not sure there's a way to iterate over chapters+sections 
> in the templates (e.g. epub-titlepage.html).
>
> Also, in another thread, John @jgm asked for an example of an EPUB with 
> this kind of inline TOC, but I can't for the life of me find the thread/GH 
> issue.  Anyway, I included and an example before/after contents.opf and the 
> new contents.xhtml in the paste as well.
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msg/pandoc-discuss/-/P_re1cppfJYJ.
For more options, visit https://groups.google.com/groups/opt_out.



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

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

end of thread, other threads:[~2012-10-26  6:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-27 21:09 EPUB toc for whole book? David Snopek
2012-04-28 10:21 ` niczero
2012-04-28 15:03   ` John MacFarlane
     [not found]     ` <20120428150316.GA405-nFAEphtLEs+AA6luYCgp0U1S2cYJDpTV9nwVQlTi/Pw@public.gmane.org>
2012-04-29 13:49       ` niczero
2012-04-29 16:31         ` John MacFarlane
     [not found]           ` <20120429163127.GC24897-nFAEphtLEs+AA6luYCgp0U1S2cYJDpTV9nwVQlTi/Pw@public.gmane.org>
2012-04-29 21:18             ` niczero
2012-04-29 21:37               ` John MacFarlane
2012-05-07 22:13       ` David Snopek
2012-10-26  5:16 ` Jason Morrison
     [not found]   ` <8cc0d96a-d364-4f03-a7bb-3b0b558fa857-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2012-10-26  6:17     ` fiddlosopher

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).