4 * Installer-specific wikitext formatting.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
24 namespace MediaWiki\Installer
;
26 class InstallDocFormatter
{
30 public static function format( $text ) {
31 return ( new self( $text ) )->execute();
34 protected function __construct( $text ) {
38 protected function execute() {
40 // Use Unix line endings, escape some wikitext stuff
41 $text = str_replace( [ '<', '{{', '[[', '__', "\r" ],
42 [ '<', '{{', '[[', '__', '' ], $text );
43 // join word-wrapped lines into one
46 $text = preg_replace( "/\n([\\*#\t])([^\n]*?)\n([^\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
47 } while ( $text != $prev );
48 // Replace tab indents with colons
49 $text = preg_replace( '/^\t\t/m', '::', $text );
50 $text = preg_replace( '/^\t/m', ':', $text );
52 $linkStart = '<span class="config-plainlink">[';
53 $linkEnd = ' $0]</span>';
55 // turn (Tnnnn) into links
58 "{$linkStart}https://phabricator.wikimedia.org/$0{$linkEnd}",
62 // turn (bug nnnn) into links
65 "{$linkStart}https://bugzilla.wikimedia.org/$1{$linkEnd}",
69 // add links to manual to every global variable mentioned
72 "{$linkStart}https://www.mediawiki.org/wiki/Manual:$0{$linkEnd}",