Created
August 20, 2014 17:27
-
-
Save AbhishekGhosh/d0606048916baafe7826 to your computer and use it in GitHub Desktop.
Convert Backticks to Code Sparing Pre Block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tcw_the_content( $content ) { | |
$content = preg_replace_callback('/<pre>(.*?)<\/pre>/s', function ($match) { | |
return '<pre>' . preg_replace('/`/', '\`', $match[1]) . '</pre>'; | |
}, $content); | |
$content = preg_replace( '/`(.*?)`/', '<code>$1</code>', $content ); | |
return $content; | |
} | |
add_filter( 'the_content', 'tcw_the_content' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment