diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/arara/scripts/rules/bib2gls.yaml |
Initial commit
Diffstat (limited to 'support/arara/scripts/rules/bib2gls.yaml')
-rw-r--r-- | support/arara/scripts/rules/bib2gls.yaml | 224 |
1 files changed, 224 insertions, 0 deletions
diff --git a/support/arara/scripts/rules/bib2gls.yaml b/support/arara/scripts/rules/bib2gls.yaml new file mode 100644 index 0000000000..9a97920717 --- /dev/null +++ b/support/arara/scripts/rules/bib2gls.yaml @@ -0,0 +1,224 @@ +!config +# Arara, the cool TeX automation tool +# Copyright (c) 2018, Paulo Roberto Massa Cereda +# All rights reserved. +# +# This rule is part of arara. +identifier: bib2gls +name: Bib2Gls +authors: +- Nicola Talbot +- Paulo Cereda +commands: +- name: The Bib2Gls software + command: > + @{ + 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 + flag: > + @{ + return ['--dir', parameters.dir] + } +- 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 + flag: > + @{ + return ['--locale', parameters.locale] + } +- identifier: group + flag: > + @{ + isTrue(parameters.group, '--group', '--no-group') + } +- identifier: interpret + flag: > + @{ + isTrue(parameters.interpret, '--interpret', '--no-interpret') + } +- identifier: breakspace + flag: > + @{ + isTrue(parameters.breakspace, '--break-space', '--no-break-space') + } +- identifier: trimfields + flag: > + @{ + isTrue(parameters.trimfields, '--trim-fields', '--no-trim-fields') + } +- identifier: recordcount + flag: > + @{ + isTrue(parameters.recordcount, '--record-count', '--no-record-count') + } +- identifier: recordcountunit + flag: > + @{ + isTrue(parameters.recordcountunit, '--record-count-unit', + '--no-record-count-unit') + } +- identifier: cite + flag: > + @{ + isTrue(parameters.cite, '--cite-as-record', '--no-cite-as-record') + } +- identifier: verbose + flag: > + @{ + isTrue(parameters.verbose, '--verbose', '--no-verbose') + } +- identifier: merge + flag: > + @{ + isTrue(parameters.merge, '--merge-wrglossary-records', + '--no-merge-wrglossary-records') + } +- identifier: uniscript + flag: > + @{ + isTrue(parameters.uniscript, '--support-unicode-script', + '--no-support-unicode-script') + } +- identifier: packages + flag: > + @{ + if (isList(parameters.packages)) { + elements = []; + foreach (element : parameters.packages) { + elements.add('--packages'); + elements.add(element); + } + return elements; + } + else { + throwError('I was expecting a list of package names.'); + } + } +- identifier: ignore + flag: > + @{ + if (isList(parameters.ignore)) { + elements = []; + foreach (element : parameters.ignore) { + elements.add('--ignore-packages'); + elements.add(element); + } + return elements; + } + else { + throwError('I was expecting a list of package names.'); + } + } +- identifier: custom + flag: > + @{ + if (isList(parameters.custom)) { + elements = []; + foreach (element : parameters.custom) { + elements.add('--custom-packages'); + elements.add(element); + } + return elements; + } + else { + throwError('I was expecting a list of package names.'); + } + } +- identifier: mapformats + flag: > + @{ + if (isList(parameters.mapformats)) { + elements = []; + foreach (element : parameters.mapformats) { + if (isList(element) && element.size() == 2) { + elements.add('--map-format'); + elements.add(element.get(0) + ':' + element.get(1)); + } + else { + throwError('I was expecting a map ' + + 'format list [<key>, <value>] '); + } + } + return elements; + } + else { + throwError('I was expecting mapformats: [ [<key>, <value>], ' + + '..., [<key>, <value>] ].'); + } + } +- identifier: options + flag: > + @{ + if (isList(parameters.options)) { + return parameters.options; + } + else { + throwError('I was expecting a list of options.'); + } + } +- identifier: clean + flag: > + @{ + return isTrue(parameters.clean, 'true', ''); + } |