Hi Lex

I've just committed your a2x patch with a couple of minor changes:
http://code.google.com/p/asciidoc/source/detail?r=26f6c1f23c8c8364c252360e49b6e89aefbaa7a6

1. I took the opportunity to simplify the a2x shell() function as the original return value wasn't being used.

2. I renamed the backend configuration file from a2x.conf to a2x-backend.py to distinguish it from the built-in config file and to make it clear that it's for the backend and is executable (the a2x.conf should have been YAML or JSON, I just took the path of least resistance at the time).

3. Renamed --backend_opts to --backend-opts for consistency.

Not part of this patch, but I stripped the backend option in your a2x.conf else it throws and error if no --backend-opts are specified:

diff --git a/packaged/a2x.conf b/packaged/a2x.conf
index f9a53c4..1b89a5d 100644
--- a/packaged/a2x.conf
+++ b/packaged/a2x.conf
@@ -75,7 +75,7 @@ class odt_archive:

 def to_odt(self):
        opts = AttrDict(base_doc=None, temp_dir=None) # TODO default base doc?
-       u = [ o.strip().split('=') for o in self.backend_opts.split('--') if o !
+       u = [ o.strip().split('=') for o in self.backend_opts.strip().split('--'
        opts.update(u)
        if opts.base_doc is None:
                die("No base document found")

I can now install asciidoc-odf as a plugin and generate ODT files using replacements3 (i.e. no line_break.py filter). Well done guys!

I do have a problem with images, this simple document generates .fodt OK but a2x fails:

8<--------
The Article Title
=================

.Tiger block image
image::tiger.png[Tiger image]
8<--------

$ a2x -b odt -v --backend-opts="--base_doc=t.ott" t.txt
 :
 :
Traceback (most recent call last):
  File "/home/srackham/bin/a2x", line 934, in <module>
    a2x.execute()
  File "/home/srackham/bin/a2x", line 356, in execute
    self.to_backend()
  File "/home/srackham/bin/a2x", line 608, in to_backend
    eval('to_%s(self)' % self.backend)
  File "<string>", line 1, in <module>
  File "/home/srackham/.asciidoc/backends/odt/a2x-backend.py", line 84, in 
to_odt
    a.make_archive(opts.base_doc, self.asciidoc_file, odt_file)
File "/home/srackham/.asciidoc/backends/odt/a2x-backend.py", line 57, in make_archive
    shutil.copyfile(mc.group(1), os.path.join(td, mc.group(2)))
  File "/usr/lib/python2.6/shutil.py", line 53, in copyfile
    fdst = open(dst, 'wb')
IOError: [Errno 2] No such file or directory: '/tmp/tmppTX8PH/Pictures/i_1.png'


Cheers, Stuart


On 05/10/11 00:36, Lex Trotman wrote:
On 4 October 2011 17:46, Lex Trotman<[email protected]>  wrote:
Hi Stuart,

Now we have plugin backends, the question of integration with a2x arises.

I propose the following simple method.

a2x gets a -b --backend option.  If it is specified a2x uses "asciidoc
--backend list" to get the directory for the backend and looks for an
a2x.conf in that directory as well as the usual places.

That a2x.conf will be expected to define a to_backendname(self)
function like the others in class A2X.

a2x will also accept a --backend-opts in a similar way to xslt-opts, etc

when --backend is specified the to_backendname() function is called
instead of the to_formatname() function.

This should allow the plugin to re-use as much as possible of a2x's
existing infrastructure.

This executes arbitary code, but a2x already does that from its conf
files anyway so there is no reduction in safety.

If it sounds ok, then I'm happy to provide a patch for this as part of
developing the ODF backend with Dag.

Cheers
Lex


See https://github.com/dagwieers/asciidoc-odf/zipped for a first pass
modified a2x and example a2x.conf backend plugin.

Cheers
Lex


--
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