summary refs log tree commit diff
path: root/pkgs/tools/misc/pandoc-acro/default.nix
blob: 1a2aff12ec77b791c5e4652e5f9df1c3408f62f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{ buildPythonApplication
, fetchPypi
, pandocfilters
, panflute
, lib
, pandoc
, pandoc-acro
, texlive
, runCommand
}:

let
  pname = "pandoc-acro";
  version = "0.10.1";

  src = fetchPypi {
    inherit pname version;
    sha256 = "sha256-JMfSQXX+BCGdFQYPFB+r08WRnhT3aXfnBNINROxCUA0=";
  };
in
buildPythonApplication {
  inherit pname version src;

  propagatedBuildInputs = [
    pandocfilters
    panflute
  ];

  # Something in the tests does not typecheck, but the tool works well.
  doCheck = false;

  passthru.tests.example-doc =
    let
        env = {
          nativeBuildInputs = [
            pandoc
            pandoc-acro
            (texlive.combine {
              inherit (texlive)
                scheme-tetex
                acro
                translations
                ;
            })
          ];
        };
      in
      runCommand "pandoc-acro-example-docs" env ''
        set -euo pipefail
        exampleFile="${pname}-${version}/tests/example.md"
        metadataFile="${pname}-${version}/tests/metadata.yaml"
        tar --extract "--file=${src}" "$exampleFile" "$metadataFile"
        mkdir $out

        pandoc -F pandoc-acro "$exampleFile" "--metadata-file=$metadataFile" \
          -T pdf -o $out/example.pdf
        pandoc -F pandoc-acro  "$exampleFile" "--metadata-file=$metadataFile" \
          -T txt -o $out/example.txt

        ! grep -q "\+afaik" $out/example.txt
      '';

  meta = with lib; {
    homepage = "https://pypi.org/project/pandoc-acro/";
    description = "Pandoc filter which manages acronyms in Pandoc flavored Markdown sources";
    license = licenses.bsd2;
    maintainers = with maintainers; [ tfc ];
  };
}