Date
1 - 4 of 4
How to add multiple formats for <li> element in <ul>
Derek Fess
I'm running DITA-OT 3.2.1
toggle quoted messageShow quoted text
Our company has rebranded, and as such we now have a new Marketing style guide. I need to format three levels of bullets. This part I've done (using the commonvariables.xml file). However, I need to make them different colors depending on which level they are at. All that I can seem to do is set the color for all levels, using the ul.li__label attribute set. If I understand correctly, I can make a new attribute set (say ul.li.li__label), but would have to call it from the lists.xsl file. This is where I am stuck. I do not know xslt well enough to know how to construct what I need. I know I need to use this piece of code from the pdf2 lists.xsl file:
|
|
Hi Derek,
I think in you case you have to create a new a new attribute set per ul level: ul.ul.li__label, ul.ul.ul.li__label, ul.ul.ul.ul.li__label, etc. And after, you have to apply dynamically these attibute-set based on item level using processAttrSetReflection named template: <xsl:template match="*[contains(@class, ' topic/ul ')]/*[contains(@class, ' topic/li ')]">I didn't test, but I think it may work. Regards, Nicolas
|
|
Ozana Dragomir
Here is our code for different bullet colours:
In lists-attr.xsl <xsl:variable name="custom-color-purple">#72166B</xsl:variable> <xsl:variable name="custom-color-blue">#6687B7</xsl:variable> <xsl:attribute-set name="ul.li__label__content"> <xsl:attribute name="text-align">start</xsl:attribute> <!-- change second level bullet color to blue and third level bullet color to purple --> <xsl:attribute name="color"> <xsl:choose> <xsl:when test="count(ancestor::*[contains(@class, ' topic/ul ')]) = 2"> <xsl:value-of select="$custom-color-blue"/> </xsl:when> <xsl:when test="count(ancestor::*[contains(@class, ' topic/ul ')]) = 3"> <xsl:value-of select="$custom-color-purple"/> </xsl:when> <xsl:otherwise>black</xsl:otherwise> </xsl:choose> </xsl:attribute> </xsl:attribute-set> I hope this helps. Best regards, Ozana
|
|
Derek Fess
On Fri, Mar 26, 2021 at 06:39 AM, Ozana Dragomir wrote:
count(ancestor::*[contains(@class, ' topic/ul ')]) = 2Ozana, thank you so much! That worked perfectly. I guess I didn't realize you could use the <xsl:choose> element in the attr file. I thought it was just defining each attribute set at a time.
|
|