Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hello all
I am still strying to convert colors from my asciidoctor files into pdf's. See previous thread. I am now trying the asciidoctor-fopub route without any success so far. I have the following basic test.adoc file: This should be [red]#printed in red#Which is translated into the following xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> <?asciidoc-toc?> <?asciidoc-numbered?> <book lang="en"> <bookinfo> <title>Untitled</title> <date>2016-02-29</date> </bookinfo> <preface> <title></title> <simpara>This should be <phrase role="red">printed in red</phrase></simpara> </preface> </book>Now I have edited the fo-pdf.xsl file in asciidoctor-fopub/build/fopub/docbook-xsl/ and I added: ... <xsl:template match="processing-instruction('asciidoc-pagebreak')"> <fo:block break-after='page'/> </xsl:template> <xsl:template match="phrase[@role='red']"> <fo:inline color="red"> <xsl:apply-templates/> </fo:inline> </xsl:template> ...I then run fopub text.xml but my pdf still does not show the red color. What am I doing wrong ? I must confess I am not an xslt expert :-) Jacques |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
You have to match the namespaced version of the element. If you want to support both DocBook 4.5. and DocBook 5, then you can look for both, separated by a pipe. <xsl:template match="db:phrase[@role='red'] | phrase[@role='red']"> <fo:inline color="red"> <xsl:apply-templates/> </fo:inline> </xsl:template> I would recommend matching all phrase elements, then using an xsl:choose/xsl:when to check for the @role attribute and pass the value through, otherwise just delegate. You can use <xsl:message>string</xsl:message> to check if your template is called (println-style debugging). -Dan Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
In reply to this post by jnilo
Thanks Dan. Your suggestion did the trick. I also tried your xsl:choose option. The following code works ok. Is that what you had in mind ?
<xsl:template match="db:phrase"> <xsl:choose> <xsl:when test="@role='blue'"> <fo:inline color="rgb(0,255,0)"> <xsl:apply-templates/> </fo:inline> </xsl:when> <xsl:when test="@role='red'"> <fo:inline color="rgb(255,0,0)"> <xsl:apply-templates/> </fo:inline> </xsl:when> <xsl:when test="@role='gray'"> <fo:inline color="rgb(128,128,128)"> <xsl:apply-templates/> </fo:inline> </xsl:when> </xsl:choose> </xsl:template>Also should not that type of code for the usual colors be included in the asciidoctor specific part of fo-pdf.xsl ? Cheers Jacques |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
Is that what you had in mind ? Exactly. Also should not that type of code for the usual colors be included in the asciidoctor specific part of fo-pdf.xsl ? I give my reasons here: I'd be open to a pull request to add semantic colors to fopub. However, I'm not working on the project myself right now. -Dan Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen |
Free forum by Nabble | Edit this page |