php:escape_a_string_for_display_in_a_webpage
Function to escape code for display in a webpage
You must replace every occurance of muppet with code, we can't use "code" because the wiki translates this meaning to highlight the code and it makes a mess of the layout.
function escapeTxtInCodeTag($txt) { $callback = function($matches) { return '<muppet' . $matches[1] . '>' . htmlentities($matches[2], ENT_QUOTES, 'UTF-8') . '</muppet>'; }; $txt = preg_replace_callback('#\<\s*code(.*?)>(.+?)<\s*\/code\s*>#', $callback, $txt); return $txt; }
/data/webs/external/dokuwiki/data/pages/php/escape_a_string_for_display_in_a_webpage.txt · Last modified: 2023/01/31 11:47 by genadmin