Single underscores for emphasis, as in mail, chat, and Markdown.
Do not cater to advanced usage like partial highlights inside words and
escapes (neither do whatsapp and slack for example); admins can use html
if really needed.
return $input; # allow html input as is if privileged
}
$html = preg_replace(
- ["/\r\n?/", "/ +\n/", "/\n/"],
- ["\n", "<br />", "</p>\n<p>"],
+ ["/\r\n?/", "/ +\n/", "/\n/", '/\b_(\w+)_\b/'],
+ ["\n", "<br />", "</p>\n<p>", '<em>$1</em>' ],
htmlspecialchars($input)
);
return "<p>$html</p>";