Open jagdeepjain opened 8 years ago
The source highlighters in Asciidoctor (pygments, rouge, coderay) don't work with fopub. The DocBook toolchain has a special way of doing source highlighting (which honestly isn't very good). If you want to use source highlighting in your PDF, I recommend using Asciidoctor PDF.
Thanks @mojavelinux I am quite comfortable with fopub :) now, and have almost good infra for writing pdf using it. Guessing now is the time to start with asciidoctor-pdf.
@mojavelinux I tried with asciidoctor-pdf and seems like footnotes at the end of page are still in development and other features like TOC and colophon etc requires additional effort that I have already pass through with fopub. Also I already configured fopub and just require the linenumber for code blocks can you please help with the usage of "The DocBook toolchain has a special way of doing source highlighting (which honestly isn't very good)" ? Pointers will be highly appreciated ! Later on once my work is completed I can test it with asciidoctor-pdf and find out the differences.
I'm sorry, I can't help you. I'm not focusing on fopub right. I don't view it as a good use of my limited time. I'm close to getting Asciidoctor PDF up to parity with the capabilities of the DocBook toolchain (including the features you mentioned) and that's where I'm putting my focus right now.
However, @getreu might be able to help you.
I could not get it work either. This is what I found:
These 2 parameters in fo.pdf
are needed:
<xsl:param name="use.extensions">1</xsl:param>
<xsl:param name="linenumbering.extensions">1</xsl:param>
http://www.sagehill.net/docbookxsl/AnnotateListing.html#LineNumbering
It seems that Apache FOP does not enable the required extension by default and "some" jar is not in CLASSPATH.
http://www.sagehill.net/docbookxsl/InstallingAnFO.html#UsingFop
Maybe this helps you further...
http://www.red-bean.com/kfogel/beautiful-code/tools/xsl/doc/extensions.html
https://lists.oasis-open.org/archives/docbook-apps/200705/msg00003.html
Thanks @getreu I will try these links and update whether success or failed :(
@getreu I followed the links you have provided and also got new link as: http://www.stevestreeting.com/2010/03/07/building-a-new-technical-documentation-tool-chain/
Did the required setup and as per the setup these are problem lines under verbatim.xsl
<xsl:choose>
<xsl:when test="function-available('sverb:numberLines')">
<xsl:copy-of select="sverb:numberLines($rtf)"/>
</xsl:when>
<xsl:when test="function-available('xverb:numberLines')">
<xsl:copy-of select="xverb:numberLines($rtf)"/>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:text>No numberLines function available.</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Not sure how to handle this :(
Just for your quick reference I have added a git repo for you review:
You need to do 3 things:
tag the piece of source code where you want line numbers to be printed with linenums
, e.g.
[source, java, linenums]
Enable line numbering
fo-pdf.xsl
<xsl:param name="use.extensions">1</xsl:param>
<xsl:param name="linenumbering.extensions">1</xsl:param>
fopub mydocument.xml -param use.extensions 1 -param linenumbering.extensions 1
Add :$APP_HOME/docbook/extensions/xalan27.jar
to your CLASSPATH in file /usr/local/java-deployment/asciidoctor-fopub/build/fopub/bin/fopub
It will look like this:
CLASSPATH=$APP_HOME/lib/fopub-1.0.0-SNAPSHOT.jar:$APP_HOME/lib/avalon-framework-api-4.3.1.jar:$APP_HOME/lib/avalon-framework-impl-4.3.1.jar:$APP_HOME/lib/fop-2.1.jar:$APP_HOME/lib/xml-resolver-1.2.jar:$APP_HOME/lib/jeuclid-fop-3.1.9.jar:$APP_HOME/lib/xslthl-2.1.0.jar:$APP_HOME/lib/fop-hyph-2.0.jar:$APP_HOME/lib/xmlgraphics-commons-2.1.jar:$APP_HOME/lib/batik-svg-dom-1.8.jar:$APP_HOME/lib/batik-bridge-1.8.jar:$APP_HOME/lib/batik-awt-util-1.8.jar:$APP_HOME/lib/batik-gvt-1.8.jar:$APP_HOME/lib/batik-transcoder-1.8.jar:$APP_HOME/lib/batik-extension-1.8.jar:$APP_HOME/lib/batik-ext-1.8.jar:$APP_HOME/lib/commons-io-1.3.1.jar:$APP_HOME/lib/jeuclid-core-3.1.9.jar:$APP_HOME/lib/batik-anim-1.8.jar:$APP_HOME/lib/batik-css-1.8.jar:$APP_HOME/lib/batik-dom-1.8.jar:$APP_HOME/lib/batik-parser-1.8.jar:$APP_HOME/lib/batik-script-1.8.jar:$APP_HOME/lib/batik-util-1.8.jar:$APP_HOME/lib/batik-xml-1.8.jar:$APP_HOME/lib/xalan-2.7.0.jar:$APP_HOME/lib/xml-apis-ext-1.3.04.jar:$APP_HOME/lib/batik-svggen-1.8.jar:$APP_HOME/lib/commons-logging-1.1.1.jar:$APP_HOME/lib/xml-apis-2.0.2.jar:$APP_HOME/docbook/extensions/xalan27.jar
Nice summary. One critique.
You should definitely not be modifying the generated build/fopub/bin/fopub file. Instead, you should add the dependency to the build.gradle file, then let Gradle regenerate the fopub script (just delete the build directory).
dependencies {
runtime 'xalan:xalan:2.7.2'
}
(there might also be a way to reference the local file, but it needs to be done in the build.gradle script or else it will get overwritten).
I can't even begin to fathom why it's necessary to add an XSLT engine to the classpath when it's already available in Java. This is one of the many reasons I find the DocBook toolchain to be such a mess.
Thanks @getreu, @mojavelinux I will update on the proceedings at my end.
@jagdeepjain: I followed @mojavelinux advice and pushed a commit here: https://github.com/getreu/asciidoctor-fopub
I had not time to test it yet. Maybe this afternoon.
Thanks @getreu I took your changes but did not succeed, I have a sample project https://github.com/jagdeepjain/sample-pdf for testing the same, have added you on this project. Please help :(
I am using two steps command to generate the pdf.
$ asciidoctor -b docbook -d book basic-example.adoc $ ./asciidoctor-fopub/fopub basic-example.xml -xsl asciidoctor-fopub/build/fopub/docbook-xsl/fo-pdf.xsl
Output:
jagdeepjain:sample-pdf jagdeepjain$ ./asciidoctor-fopub/fopub basic-example.xml -xsl asciidoctor-fopub/build/fopub/docbook-xsl/fo-pdf.xsl
sed: 1: "basic-example.xml": undefined label 'asic-example.xml'
Oct 18, 2016 12:03:53 PM org.apache.fop.hyphenation.Hyphenator getHyphenationTree
SEVERE: Couldn't find hyphenation pattern for lang="en".
Oct 18, 2016 12:03:53 PM org.apache.fop.events.LoggingEventListener processEvent
INFO: Rendered page #1.
Oct 18, 2016 12:03:53 PM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400".
Oct 18, 2016 12:03:53 PM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Font "ZapfDingbats,normal,700" not found. Substituting with "ZapfDingbats,normal,400".
Oct 18, 2016 12:03:53 PM org.apache.fop.cli.InputHandler warning
WARNING: No numberLines function available.
Oct 18, 2016 12:03:53 PM org.apache.fop.events.LoggingEventListener processEvent
INFO: Rendered page #2.
Oct 18, 2016 12:03:53 PM org.apache.fop.events.LoggingEventListener processEvent
INFO: Rendered page #3.
Oct 18, 2016 12:03:53 PM org.apache.fop.cli.Main startFOP
SEVERE: Exception
org.apache.fop.apps.FOPException: Stylesheet directed termination
javax.xml.transform.TransformerException: Stylesheet directed termination
at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:300)
at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:126)
at org.apache.fop.cli.Main.startFOP(Main.java:186)
at org.apache.fop.cli.Main.main(Main.java:217)
Caused by: javax.xml.transform.TransformerException: Stylesheet directed termination
@mojavelinux : the following does not refer to the right .jar
dependencies {
runtime 'xalan:xalan:2.7.2'
}
What we need is this one: build/fopub/docbook/extensions/xalan27.jar
.
I have no experience with gradle, how to reference the above jar?
@getreu for me nothing is working please look at https://github.com/jagdeepjain/sample-pdf and suggest what I am missing in my setup.
There are three options to getting the right jar
The only way to get experience with Gradle is just to try. It's just a programming tool like any other.
I download fop-2.1 and was able to generate the pdf successfully with code blocks having line numbers. The same xml is not working with fopub even though I have set required classpath. Seems to be a bug in fopub.
I committed the solution no. 3 to https://github.com/getreu/asciidoctor-fopub Could you have a look? It should work out of the box.
Thanks @mojavelinux, @getreu 👍 it worked for me :) will you be merging with the main branch anytime sooner ?
@mojavelinux Dan, I wrote you through the email function of our forum. Has this email reached you? Best Jens
@jagdeepjain : has your test document also tables and figures with captions, headlines, titlepage etc...? If yes do they all appear correctly?
@getreu thanks for asking and cross checking, I will update you soon.
@getreu sorry for working on this so late, I build up my docbook using the code https://github.com/getreu/asciidoctor-fopub and the tables, chapter headers, section headers and title page were happily generated as was earlier.
I saw below difference: (I guess this are configuration points that I can take care of it )
Many thanks for taking care of this 👍
If you have merge your code to mainstream I can close this issue.
Both are intentional layout improvements. Thank you for testing!
@getreu seems like changes are not visible now, could not see changes made in https://github.com/getreu/asciidoctor-fopub/commit/64062e80425d652d9a9de4e2b001fa11dba24e8a#diff-2559ef435ce261390c6a1bb7f3419fcb this repo as well as in https://github.com/getreu/asciidoctor-fopub/ repo. can you please let know how to get line numbers now?
Hello, after pull request #73 I discovered issue #74. The new download location does not include the directory asciidoctor-fopub/build/fopub/docbook/extensions
which you need. Solution: get if from some other place and download it separately. Sorry.
This should work:
xalan27.jar
(my md5: 9098eed8dc523b432acfb2596eec3d47) from hereasciidoctor-fopub/build/fopub/docbook/extensions
test_linenums.adoc
:
= tmp6 : Notes
[source,ruby,linenums]
----
ORDERED_LIST_KEYWORDS = {
'loweralpha' => 'a',
'lowerroman' => 'i',
'upperalpha' => 'A',
'upperroman' => 'I'
#'lowergreek' => 'a'
#'arabic' => '1'
#'decimal' => '1'
}
----
Thanks @getreu, but it did not work for me.
Configured in the adoc
and in the file calling as below:
Also set below:
While trying to set:
getting an exception: