summaryrefslogtreecommitdiff
path: root/support/arara/scripts/rules/arara-rule-detex.yaml
blob: 3bec681ceb7132c6d11678b89036ae66f438ad94 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
!config
# Arara, the cool TeX automation tool
# Copyright (c) 2023, Island of TeX
# All rights reserved.
#
# This rule is part of arara.
identifier: detex
name: DeTeX
authors:
- Island of TeX
commands:
- name: The DeTeX program
  command: >
    @{
        c = getCommand('detex', references, mode, follow, math, spaces,
                       words, environments, reference.fileName);
        if (output.isEmpty()) {
          return c;
        }
        else {
            p = unsafelyExecuteSystemCommand(c);
            if (p.first == 0) {
                return writeToFile(toFile(output[0]), p.second, false);
            }
            else {
                return false;
            }
        }
    }
arguments:
- identifier: references
  flag: >
    @{
        return isTrue(parameters.references, '-c');
    }
- identifier: mode
  flag: >
    @{
        modes = [ 'latex' : '-l', 'tex' : '-t' ];
        if (modes.keySet().contains(parameters.mode)) {
            return modes.get(parameters.mode);
        }
        else {
            throwError('I was expecting either the TeX or LaTeX mode.');
        }
    }
- identifier: follow
  flag: >
    @{
        return isFalse(parameters.follow, '-n');
    }
- identifier: math
  flag: >
    @{
        return isFalse(parameters.math, '-r');
    }
- identifier: spaces
  flag: >
    @{
        return isTrue(parameters.spaces, '-s');
    }
- identifier: words
  flag: >
    @{
        return isTrue(parameters.words, '-w');
    }
- identifier: environments
  flag: >
    @{
        if (!isList(parameters.environments)) {
            throwError('I was expecting a list of environments.');
        }
        else {
            return [ '-e', String.join(',', parameters.environments) ];
        }
    }
- identifier: output
  flag: >
    @{
        return parameters.output;
    }