As an alternative to formatting keywords with raw HTML, you could use Unicode โmathematical boldโ characters.
๐๐จ๐ฆ๐ฆ๐๐ง๐ญ this makes me sad;
๐ข๐ง๐ญ๐๐ ๐๐ซ ๐ฉ๐ซ๐จ๐๐๐๐ฎ๐ซ๐ square(n);
๐ฏ๐๐ฅ๐ฎ๐ n; ๐ข๐ง๐ญ๐๐ ๐๐ซ n;
square := n ร n;
๐ฉ๐ซ๐จ๐ square = (๐ข๐ง๐ญ n) ๐ข๐ง๐ญ :
(n ร n);
Unlike some other uses of Unicode mathematical bold (bypassing the lack of availability of formatting markup, especially when shitposting), this is arguably a correct use of those characters: they were meant to be used when writing mathematical notation, where what would otherwise be purely stylistic formatting may carry semantic meaning. To the extent you can consider computer code a form of mathematical notation (which, I think, is not that much of a stretch), this is pretty much exactly what happens here.
Advantages of this approach: the bolding is preserved even when you copy the code as plaintext (unlike HTML formatting), and it may be easily converted to stropped form via little more than search-and-replace. Disadvantages: some systems may lack the necessary font support to display the characters, and even on those that do support them, the characters may render as proportionally-spaced, even if the ambient font is fixed-width, which means column-aligned spacing is going to be spoiled. Also, some poorly-written screen readers will not be able to read it.
Since inputting those characters can be a hassle, hereโs a short, hastily-written user script to make that easier (known to work on Firefox 91 ESR with Greasemonkey):
// ==UserScript==
// @name ๐๐ฅ๐ ๐จ๐ฅ๐ข๐ณ๐๐ซ.
// @grant none
// @match https://retrocomputing.stackexchange.com/*
// @match https://retrocomputing.meta.stackexchange.com/*
// ==/UserScript==
const embolden = text => {
text = text.replace(/[A-Z]/g, c =>
String.fromCodePoint(c.charCodeAt(0) - 0x41 + 0x1d400));
text = text.replace(/[a-z]/g, c =>
String.fromCodePoint(c.charCodeAt(0) - 0x61 + 0x1d41a));
text = text.replace(/[0-9]/g, c =>
String.fromCodePoint(c.charCodeAt(0) - 0x30 + 0x1d7ce));
return text;
};
const link = document.createElement('a');
link.accessKey = ';';
link.addEventListener('click', ev => {
const textarea = document.querySelector('input:focus, textarea:focus');
if (!textarea || textarea.value == null)
return;
let text0 = textarea.value.substring(
textarea.selectionStart, textarea.selectionEnd);
if (!text0)
text0 = prompt('Enter text');
const text1 = embolden(text0);
const cur = textarea.selectionStart;
textarea.focus();
document.execCommand('insertText', false, text1);
textarea.selectionStart = cur + (text0 ? 0 : text1.length);
textarea.selectionEnd = cur + text1.length;
});
document.body.appendChild(link);
After installing the script with your favourite method of instaling user scripts, press Alt+; or Alt+Shift+; (this may vary depending on your browser) to activate and enter the ALGOL keyword in ASCII characters. The script should replace ASCII letters and numbers within the selected text with their mathematical bold counterparts. With an empty selection, it will prompt you for the word to insert.