Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add styling for table header and striping in docbook converter #4421

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

snaggen
Copy link

@snaggen snaggen commented Mar 20, 2023

Adds a tab style attribute with striping and header background value if they are present. The actual table striping is now handled downstream in docbook xsl. Replaces pulls #4412 and #4413

An example of the table.row.properties needed to use these features

<xsl:template name="table.row.properties">
   <xsl:choose>
    <xsl:when test="$bgcolor != ''">
        <xsl:attribute name="background-color">
            <xsl:value-of select="$bgcolor" />
        </xsl:attribute>
    </xsl:when>
    <xsl:when test="contains($tabstyle, 'stripes-odd')">
        <xsl:if test="$rownum mod 2 != 0 and not(ancestor::thead)">
          <xsl:attribute name="background-color"><xsl:value-of select="$table.row.background-color"/></xsl:attribute>
          <!-- <xsl:attribute name="background-color">#50A0F0</xsl:attribute> -->
        </xsl:if>
    </xsl:when>
    <xsl:when test="contains($tabstyle, 'stripes-even')">
        <xsl:if test="$rownum mod 2 = 0">
            <xsl:attribute name="background-color"><xsl:value-of select="$table.row.background-color"/></xsl:attribute>
            <!-- <xsl:attribute name="background-color">#F0A050</xsl:attribute> -->
        </xsl:if>
    </xsl:when>
    <xsl:when test="contains($tabstyle, 'stripes-all')">
        <xsl:if test="$rownum mod 2 = 0">
            <xsl:attribute name="background-color"><xsl:value-of select="$table.zebra-even.background-color"/></xsl:attribute>
            <!-- <xsl:attribute name="background-color">#F0A050</xsl:attribute> -->
        </xsl:if>
        <xsl:if test="$rownum mod 2 != 0 and not(ancestor::thead)">
          <xsl:attribute name="background-color"><xsl:value-of select="$table.zebra-odd.background-color"/></xsl:attribute>
          <!-- <xsl:attribute name="background-color">#50A0F0</xsl:attribute> -->
        </xsl:if>
    </xsl:when>
  </xsl:choose>

  <xsl:if test="ancestor::thead">
    <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
    <xsl:if test="ancestor::table[@role='headerbg'] or ancestor::informaltable[@role='headerbg']">
        <xsl:attribute name="background-color">
            <xsl:value-of select="$table.heading.background-color"/>
        </xsl:attribute>
    </xsl:if>
  </xsl:if>
</xsl:template>

EDIT 2024-01-08: Updated the example to work with the latest changes

@mojavelinux
Copy link
Member

tabstyle does seem to be a standard attribute in DocBook, so we're now heading in the right direction. Are these values standardized anywhere?

@snaggen
Copy link
Author

snaggen commented Mar 20, 2023

There doesn't seem to be any standardization of these values according to our research.

Copy link
Member

@mojavelinux mojavelinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with adding tabstyle for table stripes. However, I'd like to stick with the same names that are used by the HTML converter. Those are as follows:

  • stripes-all
  • stripes-even
  • stripes-odd

I don't like the idea of a headerbg option. It's not part of AsciiDoc (i.e., not compliant) and I don't see why this can't be controlled using a role (e.g., .header-bg).

I can see the benefit of mapping the stripes attribute to tabstyle (or a role) since that way you don't need to define it twice.

Also, please add a test.

@snaggen
Copy link
Author

snaggen commented Jan 5, 2024

I have now fixed the tabstyle names, removed the headerbg and added a test. However, I'm not that fluent in ruby, so I hope the test works. I had trouble running all the tests on my machine due to ruby gem issues... but I was able to run this single test and it seemed to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants