summaryrefslogtreecommitdiff
path: root/support/arara/scripts/rules/knitr.yaml
blob: feb6b1847c871385d070aad5ebfd3a2d712e61a7 (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
!config
# Arara, the cool TeX automation tool
# Copyright (c) 2020, Island of TeX 
# All rights reserved.
#
# This rule is part of arara.
identifier: knitr
name: knitr
authors:
- Adam Liter
- Island of TeX
commands:
- name: knitr
  command: >
    @{
        elements = [];
        if (!isEmpty(tangle)) elements.add('tangle = ' + tangle);
        if (!isEmpty(quiet)) elements.add('quiet = ' + quiet);
        elements.add('envir = ' + envir);
        elements.add('encoding = ' + encoding);
        return getCommand('Rscript', '-e',
               'library(knitr); knit("' + reference + '", ' +
               'output = ' + isEmpty(output, 'NULL', '"' + output + '"') + ', ' +
               String.join(', ', elements) + ')');
    }
arguments:
- identifier: output
  flag: >
    @{
        return parameters.output;
    }
- identifier: tangle
  flag: >
    @{
        if(isTrue(parameters.tangle) && !parameters.containsKey('output')) {
            throwError('If you want to tangle the document, specify an output file.');
        }
        else {
            isTrue(parameters.tangle, 'TRUE', 'FALSE')
        }
    }
- identifier: quiet
  flag: >
    @{
        isTrue(parameters.quiet, 'TRUE', 'FALSE')
    }
- identifier: envir
  flag: >
    @{
        return parameters.envir;
    }
  default: 'parent.frame()'
- identifier: encoding
  flag: >
    @{
        return parameters.encoding;
    }
  default: 'getOption("encoding")'