GEX thesis source code, full text, references

undash.php 522B

12345678910111213141516171819202122232425
  1. <?php
  2. array_shift($argv);
  3. if (count($argv)==0) die("no file\n");
  4. foreach($argv as $value) {
  5. if(!file_exists($value)) die("no file ".$value."\n");
  6. }
  7. foreach($argv as $value) {
  8. echo "Cleaning $value\n";
  9. $content = file_get_contents($value);
  10. $pat = '/(\\\\(?:label|cref|Cref|ref))\\{([^}]+)\\}/';
  11. $fixed = preg_replace_callback($pat, function($match) {
  12. return $match[1] . '{' . trim(str_replace('-', '_', $match[2])) . '}';
  13. }, $content);
  14. file_put_contents($value, $fixed);
  15. }
  16. echo "OK.\n";