docbook-apps

  • 1.  TOC on kindle

    Posted 02-03-2013 23:23
    I've been building books with the ePub3 style sheets, then using kindlegen to convert them to .mobi.

    It works pretty well for most things, however, the TOC is giving me several problems.

    1) At least in the emulator, it seems like only the Kindle Paperwhite honors the hidden attribute on
      . The result is that even if toc.section.depth is set to 0 and toc.max.depth set to 1, most Kindles show a complete toc (I'm talking about the xhtml toc here, not the .ncx toc).

      2) Some kindles, e.g., first generation and the iPad and iPhone apps (again this is seen in the emulator, but I think the emulator is pretty good these days), interpret the
        elements literally, which means that you get numbering that does not appear in other instances or in ePub readers. And, since the numbering encompasses prefaces, appendixes, colophons, etc. the numbers often bear no relation to any actual chapter numbers.

        So, my question is whether there are ways to work around these problems to make the Kindle versions behave a bit more sensibly?

        Best Regards,
        Dick Hamilton
        -------
        XML Press
        XML for Technical Communicators
        http://xmlpress.net
        hamilton@xmlpress.net






  • 2.  RE: [docbook-apps] TOC on kindle

    Posted 02-04-2013 18:08
    I haven't started using EPUB3 stylesheets yet, but for my epub2 and kindle work, I finally customized the stylesheets to produce my TOC lines as p tags with useful class names that I can control in the CSS. Neither of the built in list-options for TOC seemed to work well enough for my purposes, especially when going into Kindlegen. You could try that route. Requires more CSS work, but results in much better control.

    -----Original Message-----
    From: Richard Hamilton [mailto:hamilton@xmlpress.net]
    Sent: Sunday, February 03, 2013 5:22 PM
    To: DocBook Apps
    Subject: [docbook-apps] TOC on kindle

    I've been building books with the ePub3 style sheets, then using kindlegen to convert them to .mobi.

    It works pretty well for most things, however, the TOC is giving me several problems.

    1) At least in the emulator, it seems like only the Kindle Paperwhite honors the hidden attribute on
      . The result is that even if toc.section.depth is set to 0 and toc.max.depth set to 1, most Kindles show a complete toc (I'm talking about the xhtml toc here, not the .ncx toc).

      2) Some kindles, e.g., first generation and the iPad and iPhone apps (again this is seen in the emulator, but I think the emulator is pretty good these days), interpret the
        elements literally, which means that you get numbering that does not appear in other instances or in ePub readers. And, since the numbering encompasses prefaces, appendixes, colophons, etc. the numbers often bear no relation to any actual chapter numbers.

        So, my question is whether there are ways to work around these problems to make the Kindle versions behave a bit more sensibly?

        Best Regards,
        Dick Hamilton
        -------
        XML Press
        XML for Technical Communicators
        http://xmlpress.net
        hamilton@xmlpress.net




        ---------------------------------------------------------------------
        To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
        For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org




  • 3.  Re: [docbook-apps] TOC on kindle

    Posted 02-04-2013 19:13
    Hi Jason,

    I think that may be where I end up. Do you have any examples of TOCs you've built that you can share with the group?

    Best Regards,
    Dick
    -------
    XML Press
    XML for Technical Communicators
    http://xmlpress.net
    hamilton@xmlpress.net



    On Feb 4, 2013, at 10:07 AM, Jason Zech wrote:

    > I haven't started using EPUB3 stylesheets yet, but for my epub2 and kindle work, I finally customized the stylesheets to produce my TOC lines as p tags with useful class names that I can control in the CSS. Neither of the built in list-options for TOC seemed to work well enough for my purposes, especially when going into Kindlegen. You could try that route. Requires more CSS work, but results in much better control.
    >
    > -----Original Message-----
    > From: Richard Hamilton [mailto:hamilton@xmlpress.net]
    > Sent: Sunday, February 03, 2013 5:22 PM
    > To: DocBook Apps
    > Subject: [docbook-apps] TOC on kindle
    >
    > I've been building books with the ePub3 style sheets, then using kindlegen to convert them to .mobi.
    >
    > It works pretty well for most things, however, the TOC is giving me several problems.
    >
    > 1) At least in the emulator, it seems like only the Kindle Paperwhite honors the hidden attribute on
      . The result is that even if toc.section.depth is set to 0 and toc.max.depth set to 1, most Kindles show a complete toc (I'm talking about the xhtml toc here, not the .ncx toc).
      >
      > 2) Some kindles, e.g., first generation and the iPad and iPhone apps (again this is seen in the emulator, but I think the emulator is pretty good these days), interpret the
        elements literally, which means that you get numbering that does not appear in other instances or in ePub readers. And, since the numbering encompasses prefaces, appendixes, colophons, etc. the numbers often bear no relation to any actual chapter numbers.
        >
        > So, my question is whether there are ways to work around these problems to make the Kindle versions behave a bit more sensibly?
        >
        > Best Regards,
        > Dick Hamilton
        > -------
        > XML Press
        > XML for Technical Communicators
        > http://xmlpress.net
        > hamilton@xmlpress.net
        >
        >
        >
        >
        > ---------------------------------------------------------------------
        > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
        > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
        >




  • 4.  RE: [docbook-apps] TOC on kindle

    Posted 02-04-2013 21:13
    I'll put up the customizations, if anyone finds them helpful. And a sample output.

    I worked on 3 templates, but only 1 gets heavy customization.

    In xhtml/autotoc.xsl: I removed the list-related <xsl:element> tags from the templates "make.toc" and "subtoc".

    The bigger customization to add the p and span tags I use is in the "toc.line" template. Due to our design needs, I like to be able to style chapter/part labels differently from chapter/part titles from time to time, so there are spans added inside my p tags as well. All class names are generated based on the element it is related to.

    There is probably more fiddly stuff in this than most people need, including references to some parameters I've created for my designer to use, but I don't want to simplify and give you a template that doesn't work as expected. If you don't care about the spans, you can probably simplify my template quite a bit.

    Here's a sample output from the bk-toc.html in my epub:









    Book Title



    Contents





    The Title of the Preface



    Part 1   

    The Title of Part One



    Chapter 1     

    The Title of Chapter One



    Chapter 2     

    The Title of Chapter Two



    Chapter 3     

    The Title of Chapter Three



    Part 2   

    The Title of Part Two



    Chapter 4     

    The Title of Chapter Four



    Chapter 5     

    The Title of Chapter Five





    Other Books Published by Me






    And here is the third template, the one with significant customization:

    <xsl:template name="toc.line">
    <xsl:param name="toc-context" select="."/>
    <xsl:param name="depth" select="1"/>
    <xsl:param name="depth.from.context" select="8"/>


    <xsl:attribute name="class">
    <xsl:text>toc-</xsl:text>
    <xsl:value-of select="local-name(.)"/>
    <xsl:text>-line</xsl:text>
    </xsl:attribute>

    <xsl:if test="$toc.labels != 0">


    <xsl:attribute name="class">
    <xsl:text>toc-</xsl:text>
    <xsl:value-of select="local-name(.)"/>
    <xsl:text>-label</xsl:text>
    </xsl:attribute>




    <xsl:if test="$autotoc.label.in.hyperlink = 0">
    <xsl:variable name="label">
    <xsl:apply-templates select="." mode="label.markup"/>
    </xsl:variable>

    <xsl:if test="self::d:part">
    <xsl:copy-of select="$TOCpartLabel"/>
    <xsl:copy-of select="$label"/>
    </xsl:if>

    <xsl:if test="(self::d:chapter or self::d:article)">
    <xsl:choose>
    <xsl:when test="$TOCchapterLabel = ''">
    <xsl:choose>
    <xsl:when test="$label <= 9">

    <xsl:text>  </xsl:text>
    <xsl:copy-of select="$label"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:copy-of select="$label"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
    <xsl:choose>
    <xsl:when test="$label <= 9">

    <xsl:value-of select="$TOCchapterLabel"/>
    <xsl:copy-of select="$label"/>
    <xsl:text>  </xsl:text>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$TOCchapterLabel"/>
    <xsl:copy-of select="$label"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:if>
    <xsl:if test="$label != ''">
    <xsl:value-of select="$autotoc.label.separator"/>
    </xsl:if>
    </xsl:if>

    </xsl:if>


    <xsl:attribute name="class">
    <xsl:text>toc-</xsl:text>
    <xsl:value-of select="local-name(.)"/>
    <xsl:text>-title</xsl:text>
    </xsl:attribute>

    <xsl:attribute name="href">
    <xsl:call-template name="href.target">
    <xsl:with-param name="context" select="$toc-context"/>
    <xsl:with-param name="toc-context" select="$toc-context"/>
    </xsl:call-template>
    </xsl:attribute>





    <xsl:apply-templates select="." mode="titleabbrev.markup"/>






    </xsl:template>





    -----Original Message-----
    From: Richard Hamilton [mailto:hamilton@xmlpress.net]
    Sent: Monday, February 04, 2013 1:12 PM
    To: Jason Zech
    Cc: DocBook Apps
    Subject: Re: [docbook-apps] TOC on kindle

    Hi Jason,

    I think that may be where I end up. Do you have any examples of TOCs you've built that you can share with the group?

    Best Regards,
    Dick
    -------
    XML Press
    XML for Technical Communicators
    http://xmlpress.net
    hamilton@xmlpress.net



    On Feb 4, 2013, at 10:07 AM, Jason Zech wrote:

    > I haven't started using EPUB3 stylesheets yet, but for my epub2 and kindle work, I finally customized the stylesheets to produce my TOC lines as p tags with useful class names that I can control in the CSS. Neither of the built in list-options for TOC seemed to work well enough for my purposes, especially when going into Kindlegen. You could try that route. Requires more CSS work, but results in much better control.
    >
    > -----Original Message-----
    > From: Richard Hamilton [mailto:hamilton@xmlpress.net]
    > Sent: Sunday, February 03, 2013 5:22 PM
    > To: DocBook Apps
    > Subject: [docbook-apps] TOC on kindle
    >
    > I've been building books with the ePub3 style sheets, then using kindlegen to convert them to .mobi.
    >
    > It works pretty well for most things, however, the TOC is giving me several problems.
    >
    > 1) At least in the emulator, it seems like only the Kindle Paperwhite honors the hidden attribute on
      . The result is that even if toc.section.depth is set to 0 and toc.max.depth set to 1, most Kindles show a complete toc (I'm talking about the xhtml toc here, not the .ncx toc).
      >
      > 2) Some kindles, e.g., first generation and the iPad and iPhone apps (again this is seen in the emulator, but I think the emulator is pretty good these days), interpret the
        elements literally, which means that you get numbering that does not appear in other instances or in ePub readers. And, since the numbering encompasses prefaces, appendixes, colophons, etc. the numbers often bear no relation to any actual chapter numbers.
        >
        > So, my question is whether there are ways to work around these problems to make the Kindle versions behave a bit more sensibly?
        >
        > Best Regards,
        > Dick Hamilton
        > -------
        > XML Press
        > XML for Technical Communicators
        > http://xmlpress.net
        > hamilton@xmlpress.net
        >
        >
        >
        >
        > ---------------------------------------------------------------------
        > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
        > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
        >




  • 5.  RE: [docbook-apps] TOC on kindle

    Posted 02-04-2013 21:41
    I should have mentioned also that this is for the older epub format. I have not yet looked at epub3, so I don't know if this translates.

    -----Original Message-----
    From: Jason Zech [mailto:zech@loyolapress.com]
    Sent: Monday, February 04, 2013 3:13 PM
    To: Richard Hamilton
    Cc: DocBook Apps
    Subject: RE: [docbook-apps] TOC on kindle

    I'll put up the customizations, if anyone finds them helpful. And a sample output.

    I worked on 3 templates, but only 1 gets heavy customization.

    In xhtml/autotoc.xsl: I removed the list-related <xsl:element> tags from the templates "make.toc" and "subtoc".

    The bigger customization to add the p and span tags I use is in the "toc.line" template. Due to our design needs, I like to be able to style chapter/part labels differently from chapter/part titles from time to time, so there are spans added inside my p tags as well. All class names are generated based on the element it is related to.

    There is probably more fiddly stuff in this than most people need, including references to some parameters I've created for my designer to use, but I don't want to simplify and give you a template that doesn't work as expected. If you don't care about the spans, you can probably simplify my template quite a bit.

    Here's a sample output from the bk-toc.html in my epub:









    Book Title



    Contents





    The Title of the Preface



    Part 1   

    The Title of Part One



    Chapter 1     

    The Title of Chapter One



    Chapter 2     

    The Title of Chapter Two



    Chapter 3     

    The Title of Chapter Three



    Part 2   

    The Title of Part Two



    Chapter 4     

    The Title of Chapter Four



    Chapter 5     

    The Title of Chapter Five





    Other Books Published by Me






    And here is the third template, the one with significant customization:

    <xsl:template name="toc.line">
    <xsl:param name="toc-context" select="."/>
    <xsl:param name="depth" select="1"/>
    <xsl:param name="depth.from.context" select="8"/>


    <xsl:attribute name="class">
    <xsl:text>toc-</xsl:text>
    <xsl:value-of select="local-name(.)"/>
    <xsl:text>-line</xsl:text>
    </xsl:attribute>

    <xsl:if test="$toc.labels != 0">


    <xsl:attribute name="class">
    <xsl:text>toc-</xsl:text>
    <xsl:value-of select="local-name(.)"/>
    <xsl:text>-label</xsl:text>
    </xsl:attribute>




    <xsl:if test="$autotoc.label.in.hyperlink = 0">
    <xsl:variable name="label">
    <xsl:apply-templates select="." mode="label.markup"/>
    </xsl:variable>

    <xsl:if test="self::d:part">
    <xsl:copy-of select="$TOCpartLabel"/>
    <xsl:copy-of select="$label"/>
    </xsl:if>

    <xsl:if test="(self::d:chapter or self::d:article)">
    <xsl:choose>
    <xsl:when test="$TOCchapterLabel = ''">
    <xsl:choose>
    <xsl:when test="$label <= 9">

    <xsl:text>  </xsl:text>
    <xsl:copy-of select="$label"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:copy-of select="$label"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
    <xsl:choose>
    <xsl:when test="$label <= 9">

    <xsl:value-of select="$TOCchapterLabel"/>
    <xsl:copy-of select="$label"/>
    <xsl:text>  </xsl:text>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$TOCchapterLabel"/>
    <xsl:copy-of select="$label"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:if>
    <xsl:if test="$label != ''">
    <xsl:value-of select="$autotoc.label.separator"/>
    </xsl:if>
    </xsl:if>

    </xsl:if>


    <xsl:attribute name="class">
    <xsl:text>toc-</xsl:text>
    <xsl:value-of select="local-name(.)"/>
    <xsl:text>-title</xsl:text>
    </xsl:attribute>

    <xsl:attribute name="href">
    <xsl:call-template name="href.target">
    <xsl:with-param name="context" select="$toc-context"/>
    <xsl:with-param name="toc-context" select="$toc-context"/>
    </xsl:call-template>
    </xsl:attribute>





    <xsl:apply-templates select="." mode="titleabbrev.markup"/>






    </xsl:template>





    -----Original Message-----
    From: Richard Hamilton [mailto:hamilton@xmlpress.net]
    Sent: Monday, February 04, 2013 1:12 PM
    To: Jason Zech
    Cc: DocBook Apps
    Subject: Re: [docbook-apps] TOC on kindle

    Hi Jason,

    I think that may be where I end up. Do you have any examples of TOCs you've built that you can share with the group?

    Best Regards,
    Dick
    -------
    XML Press
    XML for Technical Communicators
    http://xmlpress.net
    hamilton@xmlpress.net



    On Feb 4, 2013, at 10:07 AM, Jason Zech wrote:

    > I haven't started using EPUB3 stylesheets yet, but for my epub2 and kindle work, I finally customized the stylesheets to produce my TOC lines as p tags with useful class names that I can control in the CSS. Neither of the built in list-options for TOC seemed to work well enough for my purposes, especially when going into Kindlegen. You could try that route. Requires more CSS work, but results in much better control.
    >
    > -----Original Message-----
    > From: Richard Hamilton [mailto:hamilton@xmlpress.net]
    > Sent: Sunday, February 03, 2013 5:22 PM
    > To: DocBook Apps
    > Subject: [docbook-apps] TOC on kindle
    >
    > I've been building books with the ePub3 style sheets, then using kindlegen to convert them to .mobi.
    >
    > It works pretty well for most things, however, the TOC is giving me several problems.
    >
    > 1) At least in the emulator, it seems like only the Kindle Paperwhite honors the hidden attribute on
      . The result is that even if toc.section.depth is set to 0 and toc.max.depth set to 1, most Kindles show a complete toc (I'm talking about the xhtml toc here, not the .ncx toc).
      >
      > 2) Some kindles, e.g., first generation and the iPad and iPhone apps (again this is seen in the emulator, but I think the emulator is pretty good these days), interpret the
        elements literally, which means that you get numbering that does not appear in other instances or in ePub readers. And, since the numbering encompasses prefaces, appendixes, colophons, etc. the numbers often bear no relation to any actual chapter numbers.
        >
        > So, my question is whether there are ways to work around these problems to make the Kindle versions behave a bit more sensibly?
        >
        > Best Regards,
        > Dick Hamilton
        > -------
        > XML Press
        > XML for Technical Communicators
        > http://xmlpress.net
        > hamilton@xmlpress.net
        >
        >
        >
        >
        > ---------------------------------------------------------------------
        > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
        > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
        >


        ---------------------------------------------------------------------
        To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
        For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org