about summary refs log tree commit diff
path: root/pkgs/tools/typesetting
diff options
context:
space:
mode:
authorBjørn Forsman <bjorn.forsman@gmail.com>2013-09-23 22:48:16 +0200
committerBjørn Forsman <bjorn.forsman@gmail.com>2013-09-24 14:52:07 +0200
commita118a9897045104c8bacae315bcec68ef7ccedfa (patch)
tree6e5b5000759d718fce842b9d8cc0c65a4648d392 /pkgs/tools/typesetting
parent30559eb62630583869e36ce9b4d868f1519194f4 (diff)
downloadnixlib-a118a9897045104c8bacae315bcec68ef7ccedfa.tar
nixlib-a118a9897045104c8bacae315bcec68ef7ccedfa.tar.gz
nixlib-a118a9897045104c8bacae315bcec68ef7ccedfa.tar.bz2
nixlib-a118a9897045104c8bacae315bcec68ef7ccedfa.tar.lz
nixlib-a118a9897045104c8bacae315bcec68ef7ccedfa.tar.xz
nixlib-a118a9897045104c8bacae315bcec68ef7ccedfa.tar.zst
nixlib-a118a9897045104c8bacae315bcec68ef7ccedfa.zip
asciidoc: add odf backend, for OpenDocument output
See https://github.com/dagwieers/asciidoc-odf for more info.

This plugin has a shebang with /bin/env instead of /usr/bin/env, so update the
patchPhase to handle both cases.

WARNING/TODO: Libreoffice says "General Error. General input/output error."
when I try to open the generated .fodp files. So the odt backend works fine,
but the odp backend does not.
Diffstat (limited to 'pkgs/tools/typesetting')
-rw-r--r--pkgs/tools/typesetting/asciidoc/default.nix23
1 files changed, 21 insertions, 2 deletions
diff --git a/pkgs/tools/typesetting/asciidoc/default.nix b/pkgs/tools/typesetting/asciidoc/default.nix
index 9b5d57f7bfd2..3da510550430 100644
--- a/pkgs/tools/typesetting/asciidoc/default.nix
+++ b/pkgs/tools/typesetting/asciidoc/default.nix
@@ -9,6 +9,7 @@
 , enableAafigureFilter ? false, aafigure ? null, recursivePthLoader ? null
 # backends
 , enableDeckjsBackend ? false
+, enableOdfBackend ? false
 }:
 
 # filters
@@ -19,7 +20,7 @@ assert enableDiagFilter -> blockdiag != null && seqdiag != null && actdiag != nu
 assert enableMatplotlibFilter -> matplotlib != null && numpy != null;
 assert enableAafigureFilter -> aafigure != null && recursivePthLoader != null;
 # backends
-assert enableDeckjsBackend -> unzip != null;
+assert (enableDeckjsBackend || enableOdfBackend) -> unzip != null;
 
 let
 
@@ -69,6 +70,16 @@ let
     sha256 = "1siy1j8naj5irrrrv5bfgl4d8nal6j9pyahy4f50wmrr9wv59s46";
   };
 
+  # the odf backend is actually two plugins: odt + odp
+  odtBackendSrc = fetchurl {
+    url = "https://github.com/downloads/dagwieers/asciidoc-odf/odt-backend-0.1.zip";
+    sha256 = "1zaa97h9sx6ncxcdkl1x3ggydi7f8kjgvrnpjnkjiizi45k350kw";
+  };
+  odpBackendSrc = fetchurl {
+    url = "https://github.com/downloads/dagwieers/asciidoc-odf/odp-backend-0.1.zip";
+    sha256 = "08ya4bskygzqkfqwjllpg31qc5k08xp2k78z9b2480g8y57bfy10";
+  };
+
 in
 
 stdenv.mkDerivation rec {
@@ -130,9 +141,17 @@ stdenv.mkDerivation rec {
   '' + optionalString enableDeckjsBackend ''
     echo "Extracting deckjs backend"
     unzip -d "$out/etc/asciidoc/backends/deckjs" "${deckjsBackendSrc}"
+  '' + optionalString enableOdfBackend ''
+    echo "Extracting odf backend (odt + odp)"
+    unzip -d "$out/etc/asciidoc/backends/odt" "${odtBackendSrc}"
+    unzip -d "$out/etc/asciidoc/backends/odp" "${odpBackendSrc}"
+    # The odt backend has a TODO note about removing this hardcoded path, but
+    # the odp backend already has that fix. Copy it here until fixed upstream.
+    sed -i "s|'/etc/asciidoc/backends/odt/asciidoc.ott'|os.path.dirname(__file__),'asciidoc.ott'|" \
+        "$out/etc/asciidoc/backends/odt/a2x-backend.py"
   '' + ''
     for n in $(find "$out" . -name \*.py); do
-      sed -i -e "s,^#![[:space:]]*/usr/bin/env python,#!${python}/bin/python,g" "$n"
+      sed -i -e "s,^#![[:space:]]*.*/bin/env python,#!${python}/bin/python,g" "$n"
       chmod +x "$n"
     done
     sed -i -e "s,/etc/vim,,g" Makefile.in