Marco Pessotto
and 1 contributors


Text::Amuse::Preprocessor::Footnotes - Rearrange footnote numbering in muse docs


Given an input file, scan its footnotes and rearrange them. This means that such document:

  #title test
  Hello [1] There [1] Test [1]
  [1] first
  Hello hello

  [1] second
  [1] third

will become

  #title test
  Hello [1] There [2] Test [3]
  Hello hello

  [1] first
  [2] second
  [3] third

Given that the effects of the rearranging could be very destructive and mess up your documents, the module try to play on the safe side and will refuse to write out a file if there is a count mismatch between the footnotes and the number of references in the body.

The core concept is that the module doesn't care about the number. Only order matters.

This could be tricky if the document uses the number between square brackets for other than footnotes.

Also used internally by Text::Amuse::Preprocessor.


new(input => $infile, output => $outfile, debug => 0);

Constructor with the following options:


The input file. It must exists.


The output file. It will be written by the module if the parsing succeeds. If not specified, the module will run in dry-run mode.


Print some additional info.


Do the job, write out output and return output. On failure, set an arror and return false.

rewrite($type, $fh_in, $fh_out)

Internal method to rewrite the footnotes. Type can be primary or secondary.


Accesso to the error. If there is a error, an hashref with the following keys will be returned:


The total number of footnote references in the body.


The total number of footnotes.


The reference's numbers found in the body as a long string.


The footnote' numbers found in the body as a long string.


The unified diff between the footnotes and the references' list


Return a string with the errors caught, undef otherwise.


Return the directory name used internally to hold the temporary files.