7

I am using arara to automatically compile some tikz images as standalone files. I have a bunch of these figures and they all have the same set of directives

% arara: clean: { extensions: [ aux, bbl, bcf, blg, out, run.xml ] }
% arara: pdflatex: { options: [ '-halt-on-error' ], interaction: batchmode }
% arara: biber: { options: [ '--validate_datamodel' ] }
% arara: pdflatex: { options: [ '-halt-on-error' ], interaction: batchmode }
% arara: --> until !found('log', 'Rerun to get cross-references right.')
% arara: --> && !found('log', 'There were undefined references.')
% arara: clean: { extensions: [ aux, bbl, bcf, blg, out, run.xml ] }

I end up copying these to each image file, but that is a lot of copy and paste and updating if I get something wrong. It is almost a perfect use case for a preamble

preambles:
   mytikzimage: |
      % arara: clean: { extensions: [ aux, bbl, bcf, blg, out, run.xml ] }
      % arara: pdflatex: { options: [ '-halt-on-error' ], interaction: batchmode }
      % arara: biber: { options: [ '--validate_datamodel' ] }
      % arara: pdflatex: { options: [ '-halt-on-error' ], interaction: batchmode }
      % arara: --> until !found('log', 'Rerun to get cross-references right.')
      % arara: --> && !found('log', 'There were undefined references.')
      % arara: clean: { extensions: [ aux, bbl, bcf, blg, out, run.xml ] }

and calling arara with a -p switch: arara -p mytikzimage, but I want to use a short cut key from my editor which is setup to just call arara. What I would like to be able to do is have something like

% arara: meta: mytikzimage

in the tex file itself that would somehow know about the preamble or some directive that calls all the other directives.

6

I did a couple of tests and managed to get really close to a viable solution, but at the end of the day, the internal workflow does not allow late directives to be incorporated in the list of tasks to be executed. A hint of what I did:

!config
identifier: source
name: Source
commands:
- name: Source file
  command: >
    @{
        import com.github.cereda.arara.utils.DirectiveUtils;
        content = readFromFile(input);
        directives = DirectiveUtils.extractDirectives(content);
        directives = DirectiveUtils.validate(directives);

        /*
           I have a list of all directives from the provided file
           stored in the 'directives' variable, but that is as far
           as one can go...
        */

        return true;
    }
arguments:
- identifier: input
  flag: >
    @{
        return parameters.input;
    }
  required: true

I must say this rule is really naughty, as it's using arara's own internal classes to extact directives from the provided file. In this example, I am using an external file, but it could be an explicit list of raw strings or a complex source (like pattern matching of TeX macros, as suggested in another question).

However, I cannot inject this list to the list of directives which was constructed in a previous step. Reflection cannot help me here, and I cannot salvage much what I've done.

A possible improvement is to extend arara's return types and add directive support. That way, a simple return directives; statement in this rule would suffice to make arara include the newly extracted list of directives to the current execution workflow.

Personally, I think the best solution would be the inclusion of metadirectives which would allow early evaluation and decision making. Then I could provide an entire framework to specify such new elements in an easy manner. It does not look too complex, but I must give some thought of common scenarios.

For now, the only solution I can think of is to create a custom rule to invoke arara within arara and provide the corresponding custom preamble. On the other side of the spectrum, the files parameter could be exploited to pass directives to be executed on files other than the current one.

  • I may go the call arara from arara route, but will probably just keep cutting and pasting. – StrongBad Dec 13 '18 at 15:45

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.