for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace dokuwiki\ParserMode;
use dokuwiki\Action\AbstractAclAction;
class Acronym extends AbstractMode
{
// A list
protected $acronyms = array();
protected $pattern = '';
/**
* Acronym constructor.
*
* @param string[] $acronyms
*/
public function __construct($acronyms)
usort($acronyms, array($this,'compare'));
$this->acronyms = $acronyms;
}
/** @inheritdoc */
public function preConnect()
if (!count($this->acronyms)) return;
$bound = '[\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]';
$acronyms = array_map('Doku_Lexer_Escape', $this->acronyms);
$this->pattern = '(?<=^|'.$bound.')(?:'.join('|', $acronyms).')(?='.$bound.')';
public function connectTo($mode)
if (strlen($this->pattern) > 0) {
$this->Lexer->addSpecialPattern($this->pattern, $mode, 'acronym');
public function getSort()
return 240;
* sort callback to order by string length descending
* @param string $a
* @param string $b
* @return int
protected function compare($a, $b)
$a_len = strlen($a);
$b_len = strlen($b);
if ($a_len > $b_len) {
return -1;
} elseif ($a_len < $b_len) {
return 1;
return 0;