This could be a browser issue. The HTML source according to Firefox is:
<span class="wss-nowiki-section">abc__def</span> <span class="wss-nowiki-section">__ccc</span> ambups<span class="wss-nowiki-section">__</span>run <span class="wss-nowiki-section">ambups__run</span>
Which looks correct to me. However FF is displaying it with the weird duplication's. Browser is 78.4.1esr (64-bit) if that helps.
I've tried in Vivaldi (3.4.2066.106) and it fails in the same way. Interestingly though, Vivaldi developer tools shows the underlining and duplication in the source HTML as it is displayed. (<u> ... </u>).
Konqueror 4.14.8 displays it correctly.
Using wget
the code is identical to that which Firefox claims to be the source.
Finally I've roughed up a minimal page using cut-and-paste from wget's output which works perfectly:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test</title>
</head>
<body lang="en-GB" dir="ltr">
<h1>Heading</h1>
<p>
<span class="wss-nowiki-section">abc__def</span> <span class="wss-nowiki-section">__ccc</span> ambups<span class="wss-nowiki-section">__</span>run <span class="wss-nowiki-section">ambups__run</span>
</p>
</body>
</html>
Thanks for all your help folks. This has taken up way too much of your time for a home project so unless you really want to continue I'll understand if it is left as a "funny". I can live with having to use _ _ in documentation.