Skip to content

Instantly share code, notes, and snippets.

@peterfleck
Last active May 14, 2018 15:29
Show Gist options
  • Save peterfleck/e33c8f99667987dcb84ebf7f5c0a5b05 to your computer and use it in GitHub Desktop.
Save peterfleck/e33c8f99667987dcb84ebf7f5c0a5b05 to your computer and use it in GitHub Desktop.

Revisions

  1. peterfleck revised this gist May 14, 2018. 1 changed file with 23 additions and 1 deletion.
    24 changes: 23 additions & 1 deletion docbook-snippets.md
    Original file line number Diff line number Diff line change
    @@ -100,4 +100,26 @@ The Docbook guide can be found here [https://tdg.docbook.org/](https://tdg.docbo
    <xsl:template match="processing-instruction('hard-pagebreak')">
    <fo:block break-after="page"/>
    </xsl:template>
    ````
    ````
    ## HTML Copy RDFa attributes
    ```
    <xsl:template name="common.html.attributes">
    <xsl:param name="inherit" select="0"/>
    <xsl:param name="class" select="local-name(.)"/>
    <xsl:apply-templates select="." mode="common.html.attributes">
    <xsl:with-param name="class" select="$class"/>
    <xsl:with-param name="inherit" select="$inherit"/>
    </xsl:apply-templates>

    <xsl:apply-templates select="." mode="rdfa.html.attributes"/>
    </xsl:template>

    <xsl:template match="*" mode="rdfa.html.attributes">
    <xsl:copy-of select="@vocab"/>
    <xsl:copy-of select="@typeof"/>
    <xsl:copy-of select="@property"/>
    <xsl:copy-of select="@resource"/>
    <xsl:copy-of select="@Prefix"/>
    </xsl:template>
    ```
  2. peterfleck revised this gist May 14, 2018. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion docbook-snippets.md
    Original file line number Diff line number Diff line change
    @@ -92,4 +92,12 @@ The Docbook guide can be found here [https://tdg.docbook.org/](https://tdg.docbo
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    ```
    ```

    ## Page-break

    ```
    <xsl:template match="processing-instruction('hard-pagebreak')">
    <fo:block break-after="page"/>
    </xsl:template>
    ````
  3. peterfleck revised this gist May 14, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docbook-snippets.md
    Original file line number Diff line number Diff line change
    @@ -49,7 +49,7 @@ The Docbook guide can be found here [https://tdg.docbook.org/](https://tdg.docbo
    ```
    ## Inlines

    ### Add extras to <emphasis>
    ### Add extras to `<emphasis>`

    ```
    <xsl:template match="d:emphasis">
  4. peterfleck revised this gist May 14, 2018. 1 changed file with 73 additions and 3 deletions.
    76 changes: 73 additions & 3 deletions docbook-snippets.md
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,10 @@ The Docbook guide can be found here [https://tdg.docbook.org/](https://tdg.docbo

    ## Paragraphs

    ### Indent paragraphs
    ### Indent paragraphs and allow alignment

    ``` <xsl:attribute-set name="normal.para.spacing">
    ```
    <xsl:attribute-set name="normal.para.spacing">
    <xsl:attribute name="space-before.optimum">0em</xsl:attribute>
    <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
    <xsl:attribute name="space-before.maximum">0em</xsl:attribute>
    @@ -22,4 +23,73 @@ The Docbook guide can be found here [https://tdg.docbook.org/](https://tdg.docbo
    <fo:block text-indent="0em">
    <xsl:apply-imports/>
    </fo:block>
    </xsl:template>```
    </xsl:template>
    <xsl:attribute-set name="para.properties" use-attribute-sets="normal.para.spacing">
    <xsl:attribute name="text-align">
    <xsl:choose>
    <xsl:when test="@role = 'left'">left</xsl:when>
    <xsl:when test="@role = 'justify'">justify</xsl:when>
    <xsl:when test="@role = 'right'">right</xsl:when>
    <xsl:when test="@role = 'center'">center</xsl:when>
    <xsl:otherwise>inherit</xsl:otherwise>
    </xsl:choose>
    </xsl:attribute>
    <xsl:attribute name="text-indent">
    <xsl:choose>
    <xsl:when test="@role = 'indent'">5mm</xsl:when>
    <xsl:when test="@role = 'double-indent'">10mm</xsl:when>
    <xsl:when test="@role = 'print-no-indent'">0in</xsl:when>
    <xsl:when test="@role = 'no-indent'">0in</xsl:when>
    <xsl:otherwise>inherit</xsl:otherwise>
    </xsl:choose>
    </xsl:attribute>
    </xsl:attribute-set>
    ```
    ## Inlines

    ### Add extras to <emphasis>

    ```
    <xsl:template match="d:emphasis">
    <xsl:choose>
    <xsl:when test="@role='bold' or @role='strong'">
    <xsl:call-template name="inline.boldseq"/>
    </xsl:when>
    <xsl:when test="@role='underline'">
    <fo:inline text-decoration="underline">
    <xsl:call-template name="inline.charseq"/>
    </fo:inline>
    </xsl:when>
    <xsl:when test="@role='strikethrough' or @role='line-through'">
    <fo:inline text-decoration="line-through">
    <xsl:call-template name="inline.charseq"/>
    </fo:inline>
    </xsl:when>
    <xsl:when test="@role='overline'">
    <fo:inline text-decoration="overline">
    <xsl:call-template name="inline.charseq"/>
    </fo:inline>
    </xsl:when>
    <xsl:when test="@role='double'">
    <fo:inline border-after-style="double" border-after-width="1mm">
    <xsl:call-template name="inline.charseq"/>
    </fo:inline>
    </xsl:when>
    <xsl:otherwise>
    <xsl:variable name="depth" select="count(ancestor::d:emphasis [not(contains(' bold strong underline strikethrough ', concat(' ', @role, ' ')))] )"/>
    <xsl:choose>
    <xsl:when test="$depth mod 2 = 1">
    <fo:inline font-style="normal">
    <xsl:apply-templates/>
    </fo:inline>
    </xsl:when>
    <xsl:otherwise>
    <xsl:call-template name="inline.italicseq"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    ```
  5. peterfleck created this gist May 14, 2018.
    25 changes: 25 additions & 0 deletions docbook-snippets.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # Docbook Snippets

    The Docbook guide can be found here [https://tdg.docbook.org/](https://tdg.docbook.org/)

    ## Paragraphs

    ### Indent paragraphs

    ``` <xsl:attribute-set name="normal.para.spacing">
    <xsl:attribute name="space-before.optimum">0em</xsl:attribute>
    <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
    <xsl:attribute name="space-before.maximum">0em</xsl:attribute>
    </xsl:attribute-set>
    <xsl:template match="d:para[preceding-sibling::d:para]">
    <fo:block text-indent="5mm">
    <xsl:apply-imports/>
    </fo:block>
    </xsl:template>
    <xsl:template match="d:para[1] | d:para[preceding-sibling::*[1][not(self::d:para)]]" priority="6">
    <fo:block text-indent="0em">
    <xsl:apply-imports/>
    </fo:block>
    </xsl:template>```