Open mquinson opened 6 years ago
The first step would be to add a new include($)
primitive to the TransTractor that would factorize the code currently in each format-specific parsers, and then to use that code in each format-specific parser instead.
grep include lib/Locale/Po4a/*
). In particular, the TeX module is doing a great job to include files, but in a somewhat poor way. It proposes a read_file()
method that is a copy+edit of the read()
provided by TransTractor. We definitely want to move that feature back to TransTractor. We cannot modify TransTractor::read()
because that function is not module specific.include($)
primitive that is very similar to unshiftline($)
. unshiftline() can be used by the modules to put back a line that they took from the master file by error. In your new include()
function, you can just use unshiftline()
to add the lines of the included file into the content of the file to be parsed. Beware, you need to do so starting from the last line so that they arrive in order in {TT}{doc_in} (that is the input document in the transtractor data).
\input
in the parsed file (around https://github.com/mquinson/po4a/blob/master/lib/Locale/Po4a/TeX.pm#L1154), use your new TransTractor::include
read_file
and use the classical TransTractor versionexclude_include
option: don't include a file if its name is listed in the @exclude_include
array.include
primitive in all the modules that need to include files this way. Again, greping in the existing code will help identifying them. And again, one PR per converted module makes sense, unless you feel otherwise.Once all this factorization work is done, you can actually fix the current but, that is, extend this include($)
primitive to search not only in the current dir, but also where the master file is.
Many many thanks for your contributions.
Am I right or this could solve also the missing compliance of the include directive present in the asciidoc format? If I understand it correctly this can be be a great new feature!
Well, it would probably be possible to implement include
in ascii doc in another way (eg by duplicating the include-related code in other formats) but the Right Thing to do is certainly to factorize code between formats, as advised above.
(reported on 07/08/2004 on Alioth by myself, and manually migrated on 02/06/2018)
Comment by Jordi Vilalta on 09/08/2004:
Comment by me on 10/08/2004: