9

I have a rule which worked with the previous version of arara:

!config
# Open the every <filename>.<format> that can be opened
# The default for <filename> is the current file.
# The default for <format> is pdf. 
#
# Sample usage: 
# - if myfile.tex is the current file, all these open myfile.pdf
# % arara: showfile
# % arara: showfile: {format: pdf}
# % arara: showfile: {filename: myfile, format: pdf}
# and both these open myfile.log:
# % arara: showfile: {format: log}
# % arara: showfile: {filename: myfile, format: log}
#
identifier: showfile
name: Display
commands: 
- name: Show file
  command: >
    @{
      prefix = isWindows( [ 'cmd', '/c', 'start' ], [ 'xdg-open' ] );
      view = getBasename(reference) + '.' + format;
      return getCommand(prefix, view);
    }
arguments:
- identifier: format
  flag: >
    @{
        return parameters.format;
    }
  default: pdf

Now, if I try it with prova.tex:

% arara: pdflatex 
% arara: showfile 
% arara: showfile: {format: log}
\documentclass{article}

\begin{document}

My rule does not work anymore

\end{document}

I get the error:

Impossible to find the file "prova.[pdf]"
0

1 Answer 1

11

Version 6.0 introduced a (breaking) change in how arguments values (either default or provided) are passed to the command logic. The rationale behind this change is because we have plans for a safer and easier rule format in the future, and having a proper, explicit type scheme would be very welcome.

You can refer to our CHANGELOG for a complete list of features and fixes in the version 6 series, as well as reading about them in our lovely blog post. :)

Long story short, argument values are handled now as a list of string values, so format, as in

% arara: showfile: { format: pdf }

will be translated as

Variable Type (version 5) Type (version 6) Value (version 5) Value (version 6)
format String List of strings "pdf" [ "pdf" ]

We need to update the way this value is handled in the command logic (note: I opted for the .concat method, but using + as in the original rule works exactly the same):

view = getBasename(reference).concat('.').concat(format[0]);

Explanation: we get the first value in the format list (index count starts at zero) and concatenate it as suffix for the view variable, which holds a string value, so

Variable Value Type
format [ "pdf" ] List of strings
view "mydoc.pdf" String

Finally, we change this line from

view = getBasename(reference) + '.' + format;

to

view = getBasename(reference).concat('.').concat(format[0]);

which should do the trick.

The complete and updated showfile.yaml rule:

!config
identifier: showfile
name: Display
commands: 
- name: Show file
  command: >
    @{
      prefix = isWindows( [ 'cmd', '/c', 'start' ], [ 'xdg-open' ] );
      view = getBasename(reference).concat('.').concat(format[0]);
      return getCommand(prefix, view);
    }
arguments:
- identifier: format
  flag: >
    @{
        return parameters.format;
    }
  default: pdf

Hope it helps!

4
  • Is there a tool to convert any rule to its version-6 counterpart?
    – Diaa
    Apr 9, 2021 at 0:27
  • 1
    @Diaa I am afraid there is no conversion tool because there's no way to guess it right. It was not a change of format but type. Most user-defined rules might be fine, as getCommand flattens lists anyway. However, if there's a complex logic inside the command section, things really get tricky and need to be manually sorted out. The reference manual points out to this change... Apr 9, 2021 at 10:30
  • I am sorry for asking without complete example, but if I have this rule snippet theWindowsCommand = getCommand(pathToBashExecutive, "-l", pathToSageStartfile, "-c", "os.chdir(r'" + pathOfCurrentWorkingFolder + "'); load('" + getBasename(currentFile()) + ".sagetex.sage')"); return isWindows(theWindowsCommand, getCommand("sage", getBasename(reference) + ".sagetex.sage"));, is there something that needs to change to be fully compatible with arara v6 and future versions? Here it is the full rule script pastebin.com/SbSngQNq.
    – Diaa
    Apr 11, 2021 at 6:44
  • 1
    @Diaa nothing suspicious there, it seems... Apr 11, 2021 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.