cssgen2.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * A simple script which outputs the CSS classes for all languages
  4. * supported by GeSHi. You can access it directly to download
  5. * the CSS file. On *NIX you can also do a simple `php cssgen.php > geshi.css`.
  6. *
  7. * This file is part of GeSHi.
  8. *
  9. * GeSHi is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * GeSHi is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with GeSHi; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. * @package geshi
  24. * @subpackage contrib
  25. * @author revulo <revulon@gmail.com>
  26. * @copyright 2008 revulo
  27. * @license http://gnu.org/copyleft/gpl.html GNU GPL
  28. *
  29. */
  30. require dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'geshi.php';
  31. $geshi = new GeSHi;
  32. $languages = array();
  33. if ($handle = opendir($geshi->language_path)) {
  34. while (($file = readdir($handle)) !== false) {
  35. $pos = strpos($file, '.');
  36. if ($pos > 0 && substr($file, $pos) == '.php') {
  37. $languages[] = substr($file, 0, $pos);
  38. }
  39. }
  40. closedir($handle);
  41. }
  42. sort($languages);
  43. header('Content-Type: application/octet-stream');
  44. header('Content-Disposition: attachment; filename="geshi.css"');
  45. echo "/**\n".
  46. " * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann\n" .
  47. " * (http://qbnz.com/highlighter/ and http://geshi.org/)\n".
  48. " */\n";
  49. foreach ($languages as $language) {
  50. $geshi->set_language($language);
  51. // note: the false argument is required for stylesheet generators, see API documentation
  52. $css = $geshi->get_stylesheet(false);
  53. echo preg_replace('/^\/\*\*.*?\*\//s', '', $css);
  54. }