| 1 | # /=====================================================================\ # | ||
| 2 | # | LaTeXML::Post::Manifest | # | ||
| 3 | # | Abstract clsas for Manifest creation | # | ||
| 4 | # |=====================================================================| # | ||
| 5 | # | Part of LaTeXML: | # | ||
| 6 | # | Public domain software, produced as part of work done by the | # | ||
| 7 | # | United States Government & not subject to copyright in the US. | # | ||
| 8 | # |---------------------------------------------------------------------| # | ||
| 9 | # | Bruce Miller <bruce.miller@nist.gov> #_# | # | ||
| 10 | # | http://dlmf.nist.gov/LaTeXML/ (o o) | # | ||
| 11 | # \=========================================================ooo==U==ooo=/ # | ||
| 12 | package LaTeXML::Post::Manifest; | ||
| 13 | use strict; | ||
| 14 | use warnings; | ||
| 15 | |||
| 16 | use LaTeXML::Post; | ||
| 17 | use base qw(LaTeXML::Post::Processor); | ||
| 18 | |||
| 19 | # Options: | ||
| 20 | # format: which specification we're creating a manifest for | ||
| 21 | # siteDirectory: the directory we're analyzing | ||
| 22 | sub new { | ||
| 23 | my ($class, %options) = @_; | ||
| 24 | my $self; | ||
| 25 | |||
| 26 | if ($options{format}) { | ||
| 27 | # Abstract class constructor, we need to instantiate a specific manifest processor | ||
| 28 | my $format = ucfirst(lc(delete $options{format})); | ||
| 29 | local $@ = ''; | ||
| 30 | my $eval_return = eval { | ||
| 31 | local $LaTeXML::IGNORE_ERRORS = 1; | ||
| 32 | require "LaTeXML/Post/Manifest/$format.pm"; 1; }; | ||
| 33 | if ($eval_return && (!$@)) { | ||
| 34 | $self = eval { | ||
| 35 | local $LaTeXML::IGNORE_ERRORS = 1; | ||
| 36 | "LaTeXML::Post::Manifest::$format"->new(%options); | ||
| 37 | }; | ||
| 38 | if (!$self) { | ||
| 39 | Warn('misdefined', 'Manifest', undef, | ||
| 40 | "Manifest post-processor '$format' could not be instanciated; Skipping", $@); | ||
| 41 | $self = $class->SUPER::new(%options); } } | ||
| 42 | else { | ||
| 43 | Warn('missing', 'Manifest', undef, | ||
| 44 | "No Manifest post-processor found for format $format; Skipping", $@); | ||
| 45 | $self = $class->SUPER::new(%options); } } | ||
| 46 | else { | ||
| 47 | # Called from a concrete manifest class | ||
| 48 | $self = $class->SUPER::new(%options); | ||
| 49 | $$self{siteDirectory} = $options{siteDirectory}; | ||
| 50 | $$self{db} = $options{db}; } | ||
| 51 | |||
| 52 | return $self; } | ||
| 53 | |||
| 54 | 1; | ||
| 55 |