Text.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Concrete text token class.
  4. *
  5. * Text tokens comprise of regular parsed character data (PCDATA) and raw
  6. * character data (from the CDATA sections). Internally, their
  7. * data is parsed with all entities expanded. Surprisingly, the text token
  8. * does have a "tag name" called #PCDATA, which is how the DTD represents it
  9. * in permissible child nodes.
  10. */
  11. class HTMLPurifier_Token_Text extends HTMLPurifier_Token
  12. {
  13. /**
  14. * @type string
  15. */
  16. public $name = '#PCDATA';
  17. /**< PCDATA tag name compatible with DTD. */
  18. /**
  19. * @type string
  20. */
  21. public $data;
  22. /**< Parsed character data of text. */
  23. /**
  24. * @type bool
  25. */
  26. public $is_whitespace;
  27. /**< Bool indicating if node is whitespace. */
  28. /**
  29. * Constructor, accepts data and determines if it is whitespace.
  30. * @param string $data String parsed character data.
  31. * @param int $line
  32. * @param int $col
  33. */
  34. public function __construct($data, $line = null, $col = null)
  35. {
  36. $this->data = $data;
  37. $this->is_whitespace = ctype_space($data);
  38. $this->line = $line;
  39. $this->col = $col;
  40. }
  41. public function toNode() {
  42. return new HTMLPurifier_Node_Text($this->data, $this->is_whitespace, $this->line, $this->col);
  43. }
  44. }
  45. // vim: et sw=4 sts=4