mostly filebased Content Presentation System
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

104 行
2.5KB

  1. <?php
  2. class freaParsedown extends ParsedownExtra {
  3. function get_BlockTypes() {
  4. return $this->BlockTypes;
  5. }
  6. function deactivate_ol() {
  7. $ol_triggers= array(
  8. "0",
  9. "1",
  10. "2",
  11. "3",
  12. "4",
  13. "5",
  14. "6",
  15. "7",
  16. "8",
  17. "9"
  18. );
  19. foreach ($ol_triggers as $key) {
  20. unset($this->BlockTypes[$key]);
  21. }
  22. }
  23. function add_language_to_link_target($href) {
  24. $f3 = \Base::instance();
  25. $data = [];
  26. $base = substr($href,0,strpos($href,'?') ? : strlen($href));
  27. parse_str(parse_url($href,PHP_URL_QUERY),$data);
  28. $fragment = parse_url($href,PHP_URL_FRAGMENT);
  29. if ($f3->get('LANG') != $f3->get('default_lang')) {
  30. if (!array_key_exists('lang',$data)) {
  31. $data['lang'] = $f3->get('LANG');
  32. }
  33. }
  34. $new = $base;
  35. if (count($data) > 0) {
  36. $new .= "?" . http_build_query($data);
  37. }
  38. if ($fragment) {
  39. $new .= "#" . $fragment;
  40. }
  41. return $new;
  42. }
  43. protected function inlineEmailTag($Excerpt)
  44. {
  45. $Link = parent::inlineEmailTag($Excerpt);
  46. if (isset($Link)) {
  47. $Link['element']['attributes'] += ['data-link-text' => $Link['element']['text']];
  48. }
  49. return $Link;
  50. }
  51. protected function inlineLink($Excerpt)
  52. {
  53. $Link = parent::inlineLink($Excerpt);
  54. if (isset($Link)) {
  55. $Link['element']['attributes'] += ['data-link-text' => $Link['element']['text']];
  56. $url=&$Link['element']['attributes']['href'];
  57. if (strpos($url,':') === FALSE) {
  58. $url = $this->add_language_to_link_target($url);
  59. }
  60. $Link['extent'] = $Link['extent'];
  61. }
  62. return $Link;
  63. }
  64. protected function inlineUrl($Excerpt)
  65. {
  66. $Link = parent::inlineUrl($Excerpt);
  67. if (isset($Link)) {
  68. $Link['element']['attributes'] += ['data-link-text' => $Link['element']['text']];
  69. }
  70. return $Link;
  71. }
  72. protected function inlineUrlTag($Excerpt)
  73. {
  74. $Link = parent::inlineUrlTag($Excerpt);
  75. if (isset($Link)) {
  76. $Link['element']['attributes'] += ['data-link-text' => $Link['element']['text']];
  77. }
  78. return $Link;
  79. }
  80. }