markdown.php 1011 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Part of the Fuel framework.
  4. *
  5. * @package Fuel
  6. * @version 1.5
  7. * @author Fuel Development Team
  8. * @license MIT License
  9. * @copyright 2010 - 2013 Fuel Development Team
  10. * @link http://fuelphp.com
  11. */
  12. namespace Fuel\Core;
  13. use MarkdownExtra_Parser;
  14. /**
  15. * This is a small wrapper around the MarkdownExtra_Parser class.
  16. *
  17. * @package Fuel
  18. * @subpackage Core
  19. */
  20. class Markdown
  21. {
  22. /**
  23. * @var MarkdownExtra_Parser The MD parser instance
  24. */
  25. protected static $parser = null;
  26. /**
  27. * Load Markdown and get it setup.
  28. *
  29. * @return void
  30. */
  31. public static function _init()
  32. {
  33. if ( ! class_exists('MarkdownExtra_Parser', false))
  34. {
  35. include COREPATH.'vendor'.DS.'markdown'.DS.'markdown.php';
  36. }
  37. static::$parser = new MarkdownExtra_Parser();
  38. }
  39. /**
  40. * Runs the given text through the Markdown parser.
  41. *
  42. * @param string Text to parse
  43. * @return string
  44. */
  45. public static function parse($text)
  46. {
  47. return static::$parser->transform($text);
  48. }
  49. }