I've got item 3 in place.
I'm sure mine isn't optimized but this may help you get started.
Also, it may depend on which version of the OT you are using. Personally, I wouldn't modify the contents of cfg/, I'd make a plugin that overrides cfg/.
Anyway, in common.xsl under:
<xsl:template name="processTopicChapter">
<fo:block xsl:use-attribute-sets="topic">
<fo:marker marker-class-name="current-chapter-number">
<xsl:for-each select="key('map-id', @id)[1]">
<xsl:number format="1" count="*[contains(@class, ' bookmap/chapter ')]" />
</xsl:for-each>
</fo:marker>
In static-contents.xsl I have a lot of:
<pagenum>
<fo:inline>
<fo:retrieve-marker retrieve-class-name="current-chapter-number" />-<fo:page-number/>
</fo:inline>
</pagenum>
Then in toc.xsl:
Inside of:
<fo:inline xsl:use-attribute-sets="__toc__page-number">
<xsl:if test="not($topicType='topicPart')">
<xsl:for-each select="key('map-id', @id)[1]">
<xsl:choose>
<xsl:when test="$topicType='topicAppendix' or ancestor-or-self::*[contains(@class, ' bookmap/appendix ')]"><!-- This was the only way I could figure out what to use to determine the parent type for a child topic -->
<xsl:number format="A" count="*[contains(@class, ' bookmap/appendix ')]"/>
</xsl:when>
<xsl:when test="$topicType='topicChapter' or ancestor-or-self::*[contains(@class, ' bookmap/chapter ')]">
<xsl:number format="1" count="*[contains(@class, ' bookmap/chapter ')]"/>
</xsl:when>
<xsl:otherwise>
<xsl:number format="1" count="*[contains(@class, ' bookmap/chapter ')]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>-</xsl:if>
<fo:page-number-citation>
<xsl:attribute name="ref-id">
<xsl:call-template name="generate-toc-id"/>
</xsl:attribute>
</fo:page-number-citation>
All this stuff could probably use cleanup. I'd greatly appreciate any constructive criticism.
For item 1. I put all of those items in a <preface> tag and use:
<xsl:template name="processTopicPreface">
<fo:page-sequence master-reference="body-sequence" xsl:use-attribute-sets="__force__page__count" initial-page-number="1" format="I">
I still have a bug where if I have multiple prefaces, some of them contain numbers and some don't. Really struggling to figure out what's going on there as it seems like the numbers follow the preface and it isn't dependent on the order of the prefaces.
On your item 2, my first thought was to figure out <lines> works and see if you can apply that code to <codeblock>. I believe it respects tabs.