function exec_cmd($cmd, $file, $isRELAT, $rmHeader = 1, $finalUTF8 = true) { global $io_options; global $dayFilter; file_put_contents('php://stderr', "\n -- ({$cmd}) {$file}\n"); if ($isRELAT) { print "\n=== {$cmd} {$file} ==="; } $dayFilter = isset($io_options['day']) ? $io_options['day'] : ''; $doc = new domParser(); $doc->getHtmlBody($file, isset($io_options['utf8']) && $io_options['utf8']); $out = $doc->output($cmd, $finalUTF8, $dayFilter); if (!$isRELAT) { if ($rmHeader) { $out = str_replace(XML_HEADER1, '', $out); } $out = trim($out); } if (!isset($io_options['breaklines'])) { // na verdade no-breaklines $out = str_replace(array('<p', '<div', '<article', '<sec', '<keys', '<days'), array("\n<p", "\n<div", "\n<article", "\n<sec", "\n<keys", "\n<days"), $out); } if (isset($io_options['normaliza'])) { // normaliza texto do autor! $out = preg_replace('/(\\d)\\s+±\\s+(\\d)/us', '$1 ± $2', $out); $out = preg_replace('/([\\dp])\\s*(<|>|=)\\s*([\\dp])/ius', '$1 $2 $3', $out); } if (isset($io_options['entnum'])) { $out = utf2html($out); } return "{$out}\n"; }
} // for if ($isXML) { print "\n\n</root>\n"; } else { print "\n\n--- TOTAIS ---\n" . count(array_keys($lista)) . " arquivos analisados:"; foreach ($lista as $k => $v) { print "\n\t {$k} = " . ($v ? "sucesso" : "FALHOU NA LEITURA DO ARQUIVO HTML"); } print "\n"; } } else { file_put_contents('php://stderr', "\n-- rodando sem o TUDO, modo {$MODO}\n"); $dom = new domParser(); if ($dom->getHtmlBody($file)) { print $dom->output($MODO, $finalUTF8); } } /** * ASSERTS. * USO: * $ php assert.php * $ php assert.php -gen */ $VERSAO = '1.0'; // v1.0 de 2014-08-03 assert_options(ASSERT_CALLBACK, 'comunicaErro'); echo "---- ASSERT (v{$VERSAO}): COMPARANDO EXECUSSAO COM HOMOLOGADOS ---\n pwd = {$baseDir}\n"; die("DEBUG"); #### testa todas as options sem loop ("tudo" desligado) //rm tools/assert
function exec_cmd($cmd, $file, $isRELAT, $isMultiSec = FALSE, $rmHeader = 1, $finalUTF8 = TRUE) { global $io_options; global $dayFilter; file_put_contents('php://stderr', "\n -- ({$cmd}) {$file}\n"); if ($isRELAT) { print "\n=== {$cmd} {$file} ==="; } $dayFilter = isset($io_options['day']) ? $io_options['day'] : ''; $doc = new domParser(); // FALTA usar a $io_options['normaliza'] pro XML na lib.php $doc->getHtmlBody($file, isset($io_options['utf8']) && $io_options['utf8']); $out = $doc->output($cmd, $finalUTF8, $dayFilter, $isMultiSec); if (!$isRELAT) { if ($rmHeader) { $out = str_replace(XML_HEADER1, '', $out); } $out = trim($out); } if (!isset($io_options['breaklines'])) { // na verdade no-breaklines $out = str_replace(['<p', '<div', '<article', '<sec', '<keys', '<days'], ["\n\n\n<p", "\n\n<div", "\n\n<article", "\n\n<sec", "\n<keys", "\n<days"], $out); $out = preg_replace("/[ \\t]*\n[ \\t]*/s", "\n", $out); // trim nas quebras de linha } $out = rmClosedFormatters($out); // repete limpeza já realizada no raw if (isset($io_options['entnum'])) { $out = utf2html($out); } return "{$out}\n"; }