summaryrefslogtreecommitdiff
path: root/support/arara/scripts/rules/arara-rule-knitr.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'support/arara/scripts/rules/arara-rule-knitr.yaml')
-rw-r--r--support/arara/scripts/rules/arara-rule-knitr.yaml58
1 files changed, 58 insertions, 0 deletions
diff --git a/support/arara/scripts/rules/arara-rule-knitr.yaml b/support/arara/scripts/rules/arara-rule-knitr.yaml
new file mode 100644
index 0000000000..2385589615
--- /dev/null
+++ b/support/arara/scripts/rules/arara-rule-knitr.yaml
@@ -0,0 +1,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 (!tangle.isEmpty()) elements.add('tangle = ' + tangle[0]);
+ if (!quiet.isEmpty()) elements.add('quiet = ' + quiet[0]);
+ out = output.isEmpty() ? 'NULL' : '"' + output[0] + '"';
+ elements.add('envir = ' + envir[0]);
+ elements.add('encoding = ' + encoding[0]);
+ return getCommand('Rscript', '-e',
+ 'library(knitr); knit("' + reference.getName() + '", ' +
+ 'output = ' + out + ', ' + 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")'