raw.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license, |
  9. // | that is bundled with this package in the file LICENSE, and is |
  10. // | available through the world-wide-web at |
  11. // | http://www.php.net/license/2_02.txt. |
  12. // | If you did not receive a copy of the PHP license and are unable to |
  13. // | obtain it through the world-wide-web, please send a note to |
  14. // | license@php.net so we can mail you a copy immediately. |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Paul M. Jones <pmjones@ciaweb.net> |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: raw.php,v 1.1 2004/01/04 01:35:23 pmjones Exp $
  20. /**
  21. *
  22. * This class implements a Text_Wiki rule to find sections of the source
  23. * text that are not to be processed by Text_Wiki. These blocks of "raw"
  24. * text will be rendered as they were found.
  25. *
  26. * @author Paul M. Jones <pmjones@ciaweb.net>
  27. *
  28. * @package Text_Wiki
  29. *
  30. */
  31. class Text_Wiki_Rule_raw extends Text_Wiki_Rule {
  32. /**
  33. *
  34. * The regular expression used to find source text matching this
  35. * rule.
  36. *
  37. * @access public
  38. *
  39. * @var string
  40. *
  41. */
  42. var $regex = "/```(.*)```/U";
  43. /**
  44. *
  45. * Generates a token entry for the matched text. Token options are:
  46. *
  47. * 'text' => The full matched text.
  48. *
  49. * @access public
  50. *
  51. * @param array &$matches The array of matches from parse().
  52. *
  53. * @return A delimited token number to be used as a placeholder in
  54. * the source text.
  55. *
  56. */
  57. function process(&$matches)
  58. {
  59. $options = array('text' => $matches[1]);
  60. return $this->addToken($options);
  61. }
  62. /**
  63. *
  64. * Renders a token into text matching the requested format.
  65. *
  66. * @access public
  67. *
  68. * @param array $options The "options" portion of the token (second
  69. * element).
  70. *
  71. * @return string The text rendered from the token options.
  72. *
  73. */
  74. function renderXhtml($options)
  75. {
  76. return $options['text'];
  77. }
  78. }
  79. ?>