syntax_plugin_spreadout.php, a PHP class that lets the * traditional amongst us to have double spaces after a sentence. * *
* This automatically detects and replaces double spaces after sentences. * Basically, any text that ends with a period ('.'), question mark ('?') * or exclamation point ('!'), with an optional bracket after that * punctuation, followed by two or more regular spaces, will be replaced * with a space followed by a non-breaking space entity (" "). This * makes things "spread out" by adding double space punctuation afterwards. *
* Before you ask, yes, I am a later generation than millennial. *
* ** This method always returns FALSE since no other data * can be nested inside a non-breaking space. *
* @param $aMode String The requested syntaxmode. * @return Boolean FALSE always. * @public * @see getAllowedTypes() */ function accepts($aMode) { return FALSE; } // accepts() /** * Connect lookup patterns to lexer. * * @param $aMode String The desired rendermode. * @public * @see render() */ function connectTo($aMode) { global $lang; // $this->Lexer->addSpecialPattern('(?<=[.\?\!\:]) {2,}', $aMode, 'plugin_spreadout'); // $this->Lexer->addSpecialPattern('(?<=[.\?\!\:][\)\]\}\"\']) {2,}', $aMode, 'plugin_spreadout'); // $this->Lexer->addSpecialPattern('(?<=[.\?\!\:][\]\}\"\']) {2,}', $aMode, 'plugin_spreadout'); $this->Lexer->addSpecialPattern(' {2,}', $aMode, 'plugin_spreadout'); } // connectTo() /** * Get an associative array with plugin info. * ** The returned array holds the following fields: *
* This implementation does nothing (ignoring the passed * arguments) and just returns the given $aState. *
* * @param $aMatch String The text matched by the patterns. * @param $aState Integer The lexer state for the match. * @param $aPos Integer The character position of the matched text. * @param $aHandler Object Reference to the Doku_Handler object. * @return Integer The given $aState value. * @public * @see render() * @static */ function handle($aMatch, $aState, $aPos, Doku_Handler $aHandler) { return $aState; // nothing more to do here ... } // handle() /** * Handle the actual output creation. * ** The method checks for the given $aMode and returns * FALSE when a mode isn't supported. * $aRenderer contains a reference to the renderer object * which is currently handling the rendering. * The contents of $aData is the return value of the * handle() method. *
* This implementation ignores the passed $aFormat * argument adding a raw UTF-8 character sequence to the * renderer's document. *
* * @param $aFormat String The output format to generate. * @param $aRenderer Object A reference to the renderer object. * @param $aData Integer The state value returned by handle(). * @return Boolean TRUE always. * @public * @see handle() */ function render($aFormat, Doku_Renderer $aRenderer, $aData) { if (DOKU_LEXER_SPECIAL == $aData) { $aRenderer->doc .= ' '; } // if return TRUE; } // render() } // class syntax_plugin_nbsp } // if ?>