38 lines
718B

  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2014 Carsten Brandt
  4. * @license https://github.com/cebe/markdown/blob/master/LICENSE
  5. * @link https://github.com/cebe/markdown#readme
  6. */
  7. namespace cebe\markdown\inline;
  8. /**
  9. * Adds strikeout inline elements
  10. */
  11. trait StrikeoutTrait
  12. {
  13. /**
  14. * Parses the strikethrough feature.
  15. * @marker ~~
  16. */
  17. protected function parseStrike($markdown)
  18. {
  19. if (preg_match('/^~~(.+?)~~/', $markdown, $matches)) {
  20. return [
  21. [
  22. 'strike',
  23. $this->parseInline($matches[1])
  24. ],
  25. strlen($matches[0])
  26. ];
  27. }
  28. return [['text', $markdown[0] . $markdown[1]], 2];
  29. }
  30. protected function renderStrike($block)
  31. {
  32. return '<del>' . $this->renderAbsy($block[1]) . '</del>';
  33. }
  34. }