asciidoctor / asciidoctor-backends

Backends (i.e., templates) for Asciidoctor, a Ruby port of AsciiDoc.
http://asciidoctor.org
Other
65 stars 73 forks source link

Invoking latex converter from elsewhere #102

Open jxxcarlson opened 9 years ago

jxxcarlson commented 9 years ago

Am trying to set things up so that I can invoke asciidoctor -r ./latex_converter.rb -b latex from other than the directory /Users/carlson/Dropbox/prog/git/asciidoctor-backends/ruby/latex. This to facilitate giving the converter a real workout with real documents.

This works:

$ pwd
/Users/carlson/Dropbox/prog/git/asciidoctor-backends/ruby/latex
 $ asciidoctor -r ./latex_converter.rb -b latex test/sample1.adoc -o foo.tex

The below doesn't. Any suggestions?

 $ pwd
/Users/carlson/Dropbox/Beijing_2014/hodge/text
 $ export LTC=/Users/carlson/Dropbox/prog/git/asciidoctor-backends/latex_converter.rb
 $ echo $LTC
/Users/carlson/Dropbox/prog/git/asciidoctor-backends/latex_converter.rb
 $ asciidoctor -r $LTC -b latex 002-Algebraic_Varieties.ad -o foo.tex
asciidoctor: FAILED: '/Users/carlson/Dropbox/prog/git/asciidoctor-backends/latex_converter.rb' 
could not be loaded
jirutka commented 9 years ago

Asciidoctor backends really should be packaged as Ruby gems, especially when it’s not just a set of templates, but contain some Ruby sources. Then this problem (with LOAD_PATH) would not occur. @mojavelinux has already mentioned it in #57 – we need some support in the Asciidoctor core for loading backends from gems. It shouldn’t be hard to implement it; I’d like to do that, but I’m currently pretty busy with refactoring of HTML5 templates, so maybe later.

jxxcarlson commented 9 years ago

This, or some other convenient system would be great. I need a better installation to really exercise the latex backend.

One thing I need guidance on: I believe the preprocessor converts things like -- into html entity sequences like  —  -- LaTeX chokes on these. I would rather cut them off early rather than postprocess them out. (I will look at the preprocessor code, but any hints are welcome).

jirutka commented 9 years ago

You can completely disable substitutions or allow just some subset, see docs here. Is it a suitable solution for this problem?

BTW, I can highly recommend to use XeLaTeX – it knows Unicode (no more cryptic escape codes), TrueType and OpenType fonts (use truly high quality fonts without conversions) and other features that everyone expects in the 21st century… :smirk_cat:

mojavelinux commented 9 years ago

It's time to graduate! See #107.

Asciidoctor backends really should be packaged as Ruby gems

There are two things to consider here.

First, we should package the backend templates so they can be used from the load path while in incubation (and for the reference templates). That would necessitate wiring the -T flag to the LOAD_PATH (we could use the Gem interface or a gem like hike).

For new converters like LaTeX, this repository serves as an incubator. Eventually, each dedicated converter should become it's own repository (much like -pdf and -epub3). Once the converter is published as a gem, it's possible to load it from the LOAD_PATH using the -r flag. Once we complete #107, publish asciidoctor-latex, and you install the asciidoctor-latex gem, you should be able to run:

asciidoctor -r asciidoctor-latex -b latex test/sample1.adoc

Thus, I think the resolution to this issue is to proceed with #107.