Extension:BacktickCode

Overview
This extension wraps &lt;code> tags around wikitext which is placed `between backtick characters`.

This provides a handy wiki-editing shortcut for wikis that expect a lot of inlined &lt;code> snippets in its pages, and functions similarly to the standard MediaWiki ''' -> &lt;b> bold formatting shortcut.

Backtick characters within &lt;pre> blocks will not be altered by this extension. Backticks outside of &lt;pre> blocks can also be output to the page by escaping them as \</tt>`</tt>.

Installing the extension
Make the file 'BacktickCode.php' containing the following code, and place it in the 'extensions' directory. ' and '\`' by '`'. // Text between tags is not modified. $text = preg_replace_callback('/ (.*?)<\/pre>/s', function ($match) {           return ' ' . preg_replace('/`/', '\`', $match[1]) . ' ';        }, $text); $text = preg_replace('/([^\\\\]|^)`([^`]*)`/', '$1 ', $text); $text = preg_replace('/\\\\\`/', '`', $text);

return true; } ?>

The code above requires PHP 5.3 or above. If you want to use this extension with a lower version of PHP, you need to modify backtickCodeParse to get rid of the anonymous function:

' and '\`' by '`'. // Text between tags is not modified. $text = preg_replace_callback('/ (.*?)<\/pre>/s', replaceBacktickCode, $text); $text = preg_replace('/([^\\\\]|^)`([^`]*)`/', '$1 ', $text); $text = preg_replace('/\\\\\`/', '`', $text);

return true; }

Loading the extension
At the end of LocalSettings.php, add the following.

Credits
This extension is derived from Extension:DollarSign.