diff options
author | Karl Berry <karl@freefriends.org> | 2018-10-23 20:45:07 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-10-23 20:45:07 +0000 |
commit | 84913babd1c16867f2a746fa23f10fe1ab10c329 (patch) | |
tree | 3342a73936419808715713cc818ddf54f72837b0 /Master/texmf-dist/scripts | |
parent | 5fcf3d2cf79485bd973370fdb9ae4864551762a0 (diff) |
arara (23oct18)
git-svn-id: svn://tug.org/texlive/trunk@48979 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rw-r--r-- | Master/texmf-dist/scripts/arara/arara.jar | bin | 5119284 -> 5119284 bytes | |||
-rw-r--r-- | Master/texmf-dist/scripts/arara/rules/bib2gls.yaml | 66 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/arara/rules/makeglossaries.yaml | 64 |
3 files changed, 125 insertions, 5 deletions
diff --git a/Master/texmf-dist/scripts/arara/arara.jar b/Master/texmf-dist/scripts/arara/arara.jar Binary files differindex 03519399de2..179c09f52b9 100644 --- a/Master/texmf-dist/scripts/arara/arara.jar +++ b/Master/texmf-dist/scripts/arara/arara.jar 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', ''); + } diff --git a/Master/texmf-dist/scripts/arara/rules/makeglossaries.yaml b/Master/texmf-dist/scripts/arara/rules/makeglossaries.yaml index 4dee1e1567b..562af6d149a 100644 --- a/Master/texmf-dist/scripts/arara/rules/makeglossaries.yaml +++ b/Master/texmf-dist/scripts/arara/rules/makeglossaries.yaml @@ -14,7 +14,59 @@ commands: - name: The MakeGlossaries software command: > @{ - return getCommand('makeglossaries', options, getBasename(file)); + if (isEmpty(clean)) + { + return getCommand('makeglossaries', options, getBasename(file)); + } + else { + prefix = []; + if (isUnix()) { + prefix = [ 'rm', '-f' ]; + } + else { + prefix = [ 'cmd', '/c', 'del' ]; + } + + base = getBasename(file); + removals = []; + + removals.add(getCommand(prefix, base.concat(".glsdefs"))); + + lines = readFromFile(base.concat('.').concat('aux')); + + java.util.regex.Pattern glsPattern = + java.util.regex.Pattern.compile( + "\\\\@newglossary\\{.*\\}\\{(.*)\\}\\{(.*)\\}\\{(.*)\\}"); + + java.util.regex.Pattern istPattern = + (clean == 'partial' ? null : + java.util.regex.Pattern.compile("\\\\@istfilename\\{(.*)\\}")); + + foreach (line: lines) + { + matcher = glsPattern.matcher(line); + + if (matcher.matches()) + { + foreach(extension: [matcher.group(1), matcher.group(2), matcher.group(3)]) + { + removals.add(getCommand(prefix, base.concat('.').concat(extension))); + } + } + else if (istPattern != null) + { + matcher = istPattern.matcher(line); + + if (matcher.matches()) + { + removals.add(getCommand(prefix, matcher.group(1))); + istPattern = null; + } + } + } + + return removals; + } } arguments: - identifier: options @@ -27,3 +79,13 @@ arguments: throwError('I was expecting a list of options.'); } } +- identifier: clean + flag: > + @{ + if ([ 'all', 'partial' ].contains(parameters.clean)) { + return parameters.clean; + } + else { + throwError('The provided clean value is not valid.'); + } + } |