NAME
Text::Amuse::Preprocessor::Footnotes - Rearrange footnote numbering in muse docs
DESCRIPTION
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.
METHODS
new(input => $infile, output => $outfile, debug => 0);
Constructor with the following options:
input
The input file. It must exists.
output
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.
debug
Print some additional info.
process
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.
error
Accesso to the error. If there is a error, an hashref with the following keys will be returned:
- references
-
The total number of footnote references in the body.
- footnotes
-
The total number of footnotes.
- references_found
-
The reference's numbers found in the body as a long string.
- footnotes_found
-
The footnote' numbers found in the body as a long string.
- differences
-
The unified diff between the footnotes and the references' list
error
Return a string with the errors caught, undef otherwise.
tmpdir
Return the directory name used internally to hold the temporary files.