dagwieers / asciidoc-odf

ODF backend for AsciiDoc
98 stars 26 forks source link

Wrong asciidoc backend path #47

Open eloi29 opened 9 years ago

eloi29 commented 9 years ago

Hi,

I tried to use ascii doc ODT backend.

Here are my issues:

1) Generating my own tarball, I miss asciidoc.ott file. Did I miss a step to generate it ?

2) When trying to generate odt file with your example input file, I see a backend path issue:

 [14:04:41] eloi@eloi-W541:~/DEV/repo_official/asciidoc-odf/examples$ a2x -v -b odt asciidoc-odt-test.asciidoc
a2x: args: ['-v', '-b', 'odt', 'asciidoc-odt-test.asciidoc']
a2x: executing: /usr/bin/asciidoc --backend list
/home/eloi/.asciidoc/backends/odt

a2x: found odt backend directory: /home/eloi/.asciidoc/backends/odt
a2x: loading configuration file: /home/eloi/.asciidoc/backends/odt/a2x-backend.py
a2x: resource files: []
a2x: resource directories: ['/etc/asciidoc/images', '/etc/asciidoc/stylesheets']
Traceback (most recent call last):
  File "/usr/bin/a2x", line 960, in 
    a2x.execute()[14:04:41] eloi@eloi-W541:~/DEV/repo_official/asciidoc-odf/examples$ a2x -v -b odt asciidoc-odt-test.asciidoc
a2x: args: ['-v', '-b', 'odt', 'asciidoc-odt-test.asciidoc']
a2x: executing: /usr/bin/asciidoc --backend list
/home/eloi/.asciidoc/backends/odt

a2x: found odt backend directory: /home/eloi/.asciidoc/backends/odt
a2x: loading configuration file: /home/eloi/.asciidoc/backends/odt/a2x-backend.py
a2x: resource files: []
a2x: resource directories: ['/etc/asciidoc/images', '/etc/asciidoc/stylesheets']
Traceback (most recent call last):
  File "/usr/bin/a2x", line 960, in 
    a2x.execute()
  File "/usr/bin/a2x", line 376, in execute
    self.to_backend()
  File "/usr/bin/a2x", line 634, in to_backend
    eval('to_%s(self)' % self.backend)
  File "", line 1, in 
  File "/home/eloi/.asciidoc/backends/odt/a2x-backend.py", line 87, in to_odt
    a.make_archive(opts.base_doc, self.asciidoc_file, odf_file)
  File "/home/eloi/.asciidoc/backends/odt/a2x-backend.py", line 33, in make_archive
    bz = zipfile.ZipFile(base_doc)
  File "/usr/lib/python2.7/zipfile.py", line 756, in __init__
    self.fp = open(file, modeDict[mode])
IOError: [Errno 2] No such file or directory: '/etc/asciidoc/backends/odt/asciidoc.ott'
  File "/usr/bin/a2x", line 376, in execute
    self.to_backend()
  File "/usr/bin/a2x", line 634, in to_backend
    eval('to_%s(self)' % self.backend)
  File "", line 1, in 
  File "/home/eloi/.asciidoc/backends/odt/a2x-backend.py", line 87, in to_odt
    a.make_archive(opts.base_doc, self.asciidoc_file, odf_file)
  File "/home/eloi/.asciidoc/backends/odt/a2x-backend.py", line 33, in make_archive
    bz = zipfile.ZipFile(base_doc)
  File "/usr/lib/python2.7/zipfile.py", line 756, in __init__
    self.fp = open(file, modeDict[mode])
IOError: [Errno 2] No such file or directory: '/etc/asciidoc/backends/odt/asciidoc.ott'

Wrong path is set : '/etc/asciidoc/backends' instead of '~/.asciidoc/backends/odt/asciidoc.ott'

I have a workaround doing :

diff --git a/backends/odt/a2x-backend.py b/backends/odt/a2x-backend.py
index ebf3e24..d4a7adf 100644
--- a/backends/odt/a2x-backend.py
+++ b/backends/odt/a2x-backend.py
@@ -84,6 +84,7 @@ class odt_archive:
                                oz.close()

 def to_odt(self):
+        CONF_DIR=os.path.join(os.getenv("HOME"),".asciidoc"))
        opts = AttrDict(base_doc=os.path.join(CONF_DIR, 'backends', 'odt', 'asciidoc.ott'),
                                        temp_dir=None, schema=None) # TODO set schema default location
        u = [ o.strip().split('=') for o in self.backend_opts.strip().split('--') if o != '' ]

Did I miss again something ? Thanks,

Eloi

tortoise74 commented 8 years ago

That workaround did not work for me. I instead had to copy the file to the location in /etc. Note the install instructions don't say if there is a way to install the backend for all users rather than to ~/.asciidoc. I copied the whole directory and got a message that there were two odt backends. removing the odt backend from ~/.asciidoc resolved this.

jesteria commented 5 years ago

I believe mine was the same issue. I installed the asciidoc-odf backend as instructed by the README:

$ asciidoc --backend install odt-backend.zip

Subsequently, using the "odt" backend, I would received a "missing theme" warning:

$ asciidoc -b odt doc.adoc
asciidoc: WARNING: doc.adoc: line 1: include file not found: 
/etc/asciidoc/backends/odt/asciidoc.odt.styles

And, most important, the resulting .fodt was largely unstyled.

I resolved this via the odt.conf under ~/.asciidoc/backends/odt/.

For whatever reason, the first "intrinsic attributes" listed here that I tried didn't evaluate. So, though the optimal change would seem to be to use the backend-confdir attribute, instead I ended up building the correct path via the user-dir attribute. The diff:

$ diff odt.conf odt.conf.bak
743c743
< include1::{theme%}{backend-confdir={user-dir}/backends/{backend}}/asciidoc.odt.styles[]
---
> include1::{theme%}{backenddir={asciidoc-confdir}/backends/{backend}}/asciidoc.odt.styles[]