html.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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: html.php,v 1.1 2004/01/04 01:35:23 pmjones Exp $
  20. /**
  21. *
  22. * This class implements a Text_Wiki_Rule to find source text marked as
  23. * HTML to be redndred as-is. The block start is marked by <html> on its
  24. * own line, and the block end is marked by </html> on its own line.
  25. *
  26. * @author Paul M. Jones <pmjones@ciaweb.net>
  27. *
  28. * @package Text_Wiki
  29. *
  30. */
  31. class Text_Wiki_Rule_html extends Text_Wiki_Rule {
  32. /**
  33. *
  34. * The regular expression used to parse the source text and find
  35. * matches conforming to this rule. Used by the parse() method.
  36. *
  37. * @access public
  38. *
  39. * @var string
  40. *
  41. * @see parse()
  42. *
  43. */
  44. var $regex = '/^\<html\>\n(.+)\n\<\/html\>(\s|$)/Umsi';
  45. /**
  46. *
  47. * Generates a replacement for the matched text. Token options are:
  48. *
  49. * 'text' => The text of the HTML to be rendered as-is.
  50. *
  51. * @access public
  52. *
  53. * @param array &$matches The array of matches from parse().
  54. *
  55. * @return A delimited token to be used as a placeholder in
  56. * the source text, plus any text following the HTML block.
  57. *
  58. */
  59. function process(&$matches)
  60. {
  61. $options = array('text' => $matches[1]);
  62. return $this->addToken($options) . $matches[2];
  63. }
  64. /**
  65. *
  66. * Renders a token into text matching the requested format.
  67. *
  68. * @access public
  69. *
  70. * @param array $options The "options" portion of the token (second
  71. * element).
  72. *
  73. * @return string The text rendered from the token options.
  74. *
  75. */
  76. function renderXhtml($options)
  77. {
  78. return $options['text'];
  79. }
  80. }
  81. ?>