Browse Source

fix empty lines quantity, init media links support

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

38
src/Dokuwiki/Reader.php

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

Loading…
Cancel
Save