Browse Source

fix empty lines quantity, init media links support

main
ghost 9 months ago
parent
commit
ba326b9b3c
  1. 38
      src/Dokuwiki/Reader.php

38
src/Dokuwiki/Reader.php

@ -16,19 +16,19 @@ class Reader @@ -16,19 +16,19 @@ class Reader
private array $_rule =
[
// Headers
'/^([\s]?)#([^#]+)/' => '$1#$2' . PHP_EOL,
'/^([\s]?)##([^#]+)/' => '$1##$2' . PHP_EOL,
'/^([\s]?)###([^#]+)/' => '$1###$2' . PHP_EOL,
'/^([\s]?)####([^#]+)/' => '$1###$2' . PHP_EOL,
'/^([\s]?)#####([^#]+)/' => '$1###$2' . PHP_EOL,
'/^([\s]?)######([^#]+)/' => '$1###$2' . PHP_EOL,
'/^[\s]?[=]{6}([^=]+)[=]{6}/' => '# $1' . PHP_EOL,
'/^[\s]?[=]{5}([^=]+)[=]{5}/' => '## $1' . PHP_EOL,
'/^[\s]?[=]{4}([^=]+)[=]{4}/' => '### $1' . PHP_EOL,
'/^[\s]?[=]{3}([^=]+)[=]{3}/' => '### $1' . PHP_EOL,
'/^[\s]?[=]{2}([^=]+)[=]{2}/' => '### $1' . PHP_EOL,
'/^[\s]?[=]{1}([^=]+)[=]{1}/' => '### $1' . PHP_EOL,
'/^([\s]*)#([^#]+)/' => '$1#$2' . PHP_EOL,
'/^([\s]*)##([^#]+)/' => '$1##$2' . PHP_EOL,
'/^([\s]*)###([^#]+)/' => '$1###$2' . PHP_EOL,
'/^([\s]*)####([^#]+)/' => '$1###$2' . PHP_EOL,
'/^([\s]*)#####([^#]+)/' => '$1###$2' . PHP_EOL,
'/^([\s]*)######([^#]+)/' => '$1###$2' . PHP_EOL,
'/^[\s]*[=]{6}([^=]+)[=]{6}/' => '# $1' . PHP_EOL,
'/^[\s]*[=]{5}([^=]+)[=]{5}/' => '## $1' . PHP_EOL,
'/^[\s]*[=]{4}([^=]+)[=]{4}/' => '### $1' . PHP_EOL,
'/^[\s]*[=]{3}([^=]+)[=]{3}/' => '### $1' . PHP_EOL,
'/^[\s]*[=]{2}([^=]+)[=]{2}/' => '### $1' . PHP_EOL,
'/^[\s]*[=]{1}([^=]+)[=]{1}/' => '### $1' . PHP_EOL,
// Tags
'/\*\*([^\*]{2,})\*\*/' => '$1',
@ -43,11 +43,11 @@ class Reader @@ -43,11 +43,11 @@ class Reader
'/\[\[([^\[]+)\[([A-f:0-9]*)\]([^\]]+)\]\]/' => '$1~IPv6:open~$2~IPv6:close~$3',
/// Remove extra spaces
'/\[\[\s?([^\|]+)\s?\|\s?([^\]]+)\s?\]\]/' => '[[$1|$2]]',
'/\[\[\s?([^\]]+)\s?\]\]/' => '[[$1]]',
'/\[\[\s*([^\|]+)\s*\|\s*([^\]]+)\s*\]\]/' => '[[$1|$2]]',
'/\[\[\s*([^\]]+)\s*\]\]/' => '[[$1]]',
'/\{\{\s?([^\|]+)\s?\|\s?([^\}]+)\s?\}\}/' => '{{$1|$2}}',
'/\{\{\s?([^\}]+)\s?\}\}/' => '{{$1}}',
'/\{\{\s*([^\|]+)\s*\|\s*([^\}]+)\s*\}\}/' => '{{$1|$2}}',
'/\{\{\s*([^\}]+)\s*\}\}/' => '{{$1}}',
/// Wikipedia
'/\[\[wp([A-z]{2,})>([^\|]+)\|([^\]]+)\]\]/ui' => '$3 ( https://$1.wikipedia.org/wiki/$2 )',
@ -75,6 +75,10 @@ class Reader @@ -75,6 +75,10 @@ class Reader
'/\[\[(https?:)([^\|]+)\|([^\]]+)\]\]/i' => '$3 ( $1$2 )',
'/\[\[(https?:)([^\]]+)\]\]/i' => '$1$2', // @TODO
/// Media
'/\{\{(?!https?:)([^\|]+)\|([^\}]+)\}\}/i' => PHP_EOL . '=> /$1$2' . PHP_EOL,
'/\{\{(?!https?:)([^\}]+)\}\}/i' => PHP_EOL . '=> /$1$2' . PHP_EOL,
// List
'/^[\s]?-/' => '* ',
'/^[\s]+\*/' => '*',

Loading…
Cancel
Save