summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/arara/rules/bib2gls.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/arara/rules/bib2gls.yaml')
-rw-r--r--Master/texmf-dist/scripts/arara/rules/bib2gls.yaml66
1 files changed, 62 insertions, 4 deletions
diff --git a/Master/texmf-dist/scripts/arara/rules/bib2gls.yaml b/Master/texmf-dist/scripts/arara/rules/bib2gls.yaml
index 254a362096e..9a979207172 100644
--- a/Master/texmf-dist/scripts/arara/rules/bib2gls.yaml
+++ b/Master/texmf-dist/scripts/arara/rules/bib2gls.yaml
@@ -13,10 +13,58 @@ commands:
- name: The Bib2Gls software
command: >
@{
- return getCommand('bib2gls', dir, trans, group, interpret,
- breakspace, trimfields, recordcount, recordcountunit,
- cite, verbose, merge, locale, uniscript, packages,
- ignore, custom, mapformats, options, getBasename(file));
+ if (isNotEmpty(clean))
+ {
+ prefix = [];
+ if (isUnix()) {
+ prefix = [ 'rm', '-f', '-v' ];
+ }
+ else {
+ prefix = [ 'cmd', '/c', 'del' ];
+ }
+
+ base = getBasename(file);
+ removals = [];
+
+ lines = readFromFile(base.concat('.').concat('aux'));
+
+ java.util.regex.Pattern resourcePattern =
+ java.util.regex.Pattern.compile(
+ "\\\\glsxtr@resource\\{.*\\}\\{([^\\}]+)\\}");
+
+ if (isNotEmpty(trans))
+ {
+ if (trans == getOriginalFile())
+ {
+ throwError('I cannot remove the main file reference.');
+ }
+
+ removals.add(getCommand(prefix, trans));
+ }
+ else
+ {
+ removals.add(getCommand(prefix, base.concat('.glg')));
+ }
+
+ foreach (line: lines)
+ {
+ matcher = resourcePattern.matcher(line);
+
+ if (matcher.matches())
+ {
+ removals.add(getCommand(prefix, matcher.group(1).concat('.glstex')));
+ }
+ }
+
+ return removals;
+ }
+ else
+ {
+ return getCommand('bib2gls', dir, trans, group, interpret,
+ breakspace, trimfields, recordcount, recordcountunit,
+ cite, verbose, merge, locale, uniscript, packages,
+ ignore, custom, mapformats, options, getBasename(file));
+ }
}
arguments:
- identifier: dir
@@ -27,6 +75,11 @@ arguments:
- identifier: trans
flag: >
@{
+ if ([ 'tex', 'ltx', 'cls', 'sty', 'bib',
+ 'dtx', 'ins', 'def', 'ldf' ].contains(parameters.trans)) {
+ throwError('Forbidden transcript extension');
+ }
+
return ['--log-file', getBasename(file)+"."+parameters.trans]
}
- identifier: locale
@@ -164,3 +217,8 @@ arguments:
throwError('I was expecting a list of options.');
}
}
+- identifier: clean
+ flag: >
+ @{
+ return isTrue(parameters.clean, 'true', '');
+ }