convert.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /******************************************************************************
  3. * Copyright (c) 2010 Jevon Wright and others.
  4. * All rights reserved. This program and the accompanying materials
  5. * are made available under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution, and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * or
  10. *
  11. * LGPL which is available at http://www.gnu.org/licenses/lgpl.html
  12. *
  13. *
  14. * Contributors:
  15. * Jevon Wright - initial API and implementation
  16. ****************************************************************************/
  17. /**
  18. * This file allows you to convert through the command line.
  19. * Usage:
  20. * php -f convert.php [input file]
  21. */
  22. if (count($argv) < 2) {
  23. throw new \InvalidArgumentException("Expected: php -f convert.php [input file]");
  24. }
  25. if (!file_exists($argv[1])) {
  26. throw new \InvalidArgumentException("'" . $argv[1] . "' does not exist");
  27. }
  28. $input = file_get_contents($argv[1]);
  29. require_once(__DIR__ . "/src/Html2Text.php");
  30. require_once(__DIR__ . "/src/Html2TextException.php");
  31. echo Html2Text\Html2Text::convert($input);