Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
strip p tags from figures, and set up xmllint command to fix texture …
Browse files Browse the repository at this point in the history
…ref matching
  • Loading branch information
axfelix committed May 15, 2018
1 parent 6f1e4dd commit b18bc54
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/autoload/global.php
Expand Up @@ -131,6 +131,11 @@
'epub' => array(
'command' => 'vendor/pkp/jats2epub/jats2epub'
),
'xmlfinal' => array(
'xmllint' => array(
'command' => 'xmllint',
),
),
'pdf' => array(
'wkhtmltopdf' => array(
'command' => 'module/PdfConversion/assets/wkhtmltopdf-0.11.0_rc1-amd64',
Expand Down
Expand Up @@ -196,6 +196,10 @@ protected function merge()
$figElements = $meTypesetDom->getElementsByTagName('fig');
foreach ($figElements as $figure) {
$figItem = $figElements->item($k);
$figP = $figItem->getElementsByTagName('p');
foreach ($figP as $p) {
$figItem->removeChild($p);
}
$graphic = $figItem->getElementsByTagName('graphic');
foreach ($graphic as $g) {
$children = [];
Expand Down
26 changes: 25 additions & 1 deletion module/XmlFinal/src/XmlFinal/Model/Converter/XmlFinal.php
Expand Up @@ -60,7 +60,31 @@ public function setOutputFile($outputFile)
{
$this->outputFile = $outputFile;
}


/**
* Run xmllint --format on the document to fix ref-list line length
*
* @return void
*/
protected function xmllintFormat($inputFile, $outputFile)
{
$command = new Command;
// Set the base command
$command->setCommand($this->config['xmllint']['command']);
// Just fix linebreaks in the XML
$command->addSwitch('--format');
// The otherwise-final XML
$command->addArgument($this->inputFile);
// Redirect STDOUT to file
$command->addRedirect('>');
// The now-final XML
$command->addArgument($this->outputFile);
// Run the xmllint command
$command->execute();
$this->status = $command->isSuccess();
$this->output = $command->getOutputString();
}

/**
* Copy final xml document
*/
Expand Down

0 comments on commit b18bc54

Please sign in to comment.