parser.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. use dokuwiki\Debug\PropertyDeprecationHelper;
  3. /**
  4. * Define various types of modes used by the parser - they are used to
  5. * populate the list of modes another mode accepts
  6. */
  7. global $PARSER_MODES;
  8. $PARSER_MODES = array(
  9. // containers are complex modes that can contain many other modes
  10. // hr breaks the principle but they shouldn't be used in tables / lists
  11. // so they are put here
  12. 'container' => array('listblock', 'table', 'quote', 'hr'),
  13. // some mode are allowed inside the base mode only
  14. 'baseonly' => array('header'),
  15. // modes for styling text -- footnote behaves similar to styling
  16. 'formatting' => array(
  17. 'strong', 'emphasis', 'underline', 'monospace',
  18. 'subscript', 'superscript', 'deleted', 'footnote'
  19. ),
  20. // modes where the token is simply replaced - they can not contain any
  21. // other modes
  22. 'substition' => array(
  23. 'acronym', 'smiley', 'wordblock', 'entity',
  24. 'camelcaselink', 'internallink', 'media',
  25. 'externallink', 'linebreak', 'emaillink',
  26. 'windowssharelink', 'filelink', 'notoc',
  27. 'nocache', 'multiplyentity', 'quotes', 'rss'
  28. ),
  29. // modes which have a start and end token but inside which
  30. // no other modes should be applied
  31. 'protected' => array('preformatted', 'code', 'file'),
  32. // inside this mode no wiki markup should be applied but lineendings
  33. // and whitespace isn't preserved
  34. 'disabled' => array('unformatted'),
  35. // used to mark paragraph boundaries
  36. 'paragraphs' => array('eol')
  37. );
  38. /**
  39. * Class Doku_Parser
  40. *
  41. * @deprecated 2018-05-04
  42. */
  43. class Doku_Parser extends \dokuwiki\Parsing\Parser {
  44. use PropertyDeprecationHelper {
  45. __set as protected deprecationHelperMagicSet;
  46. __get as protected deprecationHelperMagicGet;
  47. }
  48. /** @inheritdoc */
  49. public function __construct(Doku_Handler $handler = null) {
  50. dbg_deprecated(\dokuwiki\Parsing\Parser::class);
  51. $this->deprecatePublicProperty('modes', __CLASS__);
  52. $this->deprecatePublicProperty('connected', __CLASS__);
  53. if ($handler === null) {
  54. $handler = new Doku_Handler();
  55. }
  56. parent::__construct($handler);
  57. }
  58. public function __set($name, $value)
  59. {
  60. if ($name === 'Handler') {
  61. $this->handler = $value;
  62. return;
  63. }
  64. if ($name === 'Lexer') {
  65. $this->lexer = $value;
  66. return;
  67. }
  68. $this->deprecationHelperMagicSet($name, $value);
  69. }
  70. public function __get($name)
  71. {
  72. if ($name === 'Handler') {
  73. return $this->handler;
  74. }
  75. if ($name === 'Lexer') {
  76. return $this->lexer;
  77. }
  78. return $this->deprecationHelperMagicGet($name);
  79. }
  80. }