On 13/01/13 12:03, Daniel Martinez wrote:
> Hi,
> 
> I'm trying to come up with a way of executing asciidoc from java without
> any native dependency, not even the asciidoc installation. Actually, I
> found that embedding the asciidoc directory as a resource in the java
> project allows me to import it from jython with no problem at all and it
> seems to work with a few asciidoc documents I tried, using AsciiDocAPI
> as suggested in the documentation. Nevertheless it is also quite common
> for it to fail with well formed documents that are processed flawlessly
> using native python... I also tried to remove the asciidoc code from the
> java jar and set up jython syspath to point to the asciidoc installation
> and got the same errors. Has anyone succeeded in making asciidoc work
> with jython-standalone library?
> 
> I'm using JDK1.6-31 in Fedora 16 with jython-standalone 2.5.3. Asciidoc
> version is 8.6.8
> 
> As an example, the following java program tries to process the official
> doc (asciidoc.txt) and fails with the error below:
> 
> import org.python.util.PythonInterpreter;
> 
> public class AsciiDocTest {
> 
> public static void main(String[] args) {
>   PythonInterpreter python = new PythonInterpreter();                   
>            python.exec("from asciidocapi import AsciiDocAPI");
>            python.exec("asciidoc = AsciiDocAPI()");
>            python.exec("asciidoc.execute('/tmp/asciidoc.txt')");
> }
> }
> 
> *_Output_*
> Exception in thread "MainThread" Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "__pyclasspath__/asciidocapi$py.class", line 248, in execute
> asciidocapi.AsciiDocError: ERROR: asciidoc.txt: line 6023: undefined
> filter attribute in command: "{python}" "{asciidoc-file}" -b {backend}
> {asciidoc-args}{lang? -a "lang={lang}@"}{icons? -a icons -a
> "iconsdir={iconsdir}"}{imagesdir? -a "imagesdir={imagesdir}"}{data-uri?
> -a data-uri} -a "indir={indir}"{trace? -a "trace={trace}"}{blockname? -a
> "blockname={blockname}"} -s -

The Python executable attribute ({python}) is not being set.

In asciidoc.py it is set when asciidoc() is executed with:

  document.attributes['python'] = sys.executable

Jython returns None if the jython interpreter executable is not being
executed which means that source using filters written in Python or
containing tables with an 'asciidoc' column style won't work.

If you compile using the Jython interpreter it will work e.g.

  jython asciidoc.py doc/asciidoc.txt

I don't know Jython/Java well enough to figure out a workaround.


Cheers, Stuart





> 
> Thanks,
> Daniel
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "asciidoc" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/asciidoc/-/tIfQcQ8z5u8J.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/asciidoc?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"asciidoc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/asciidoc?hl=en.

Reply via email to