7

It seems that HTML entities are not parsed in chat. What's the rationale for this?

In my humble opinion, HTML entities can be very useful. I would be able to freely type "—" with — and "–" with – instead of looking up their Unicode, instead of the really short and annoying hyphen. Heck, the minus sign is itself larger than a hyphen.

So, what is the rationale behind not allowing HTML entities? If it's potential for abuse, wouldn't it be better to disallow posting a message containing nothing but  1? Or is there some other reason these aren't parsed?


1: Even so, people can easily post empty messages, so this is not a great counter.

  • 1
    To keep people from typing silly dashes like — and –. Make real sentences, you crazy dash person! – Jason C Mar 29 '17 at 21:42
  • @Jason Here's a sentence: ಠ_ಠ – Marshmallow Mar 29 '17 at 21:43
  • (╯°□°)╯︵ ┻━┻️️️ – Jason C Mar 29 '17 at 21:47
  • Great question. Mdash is my favorite punctuation mark. – Glenn Ferrie Mar 29 '17 at 22:07
  • 2
    I do have to admit to a love of →, myself... Btw as for "abuse" (although I really don't see an issue that can't be solved with a flag if it's truly a problem) another approach would be to explicitly whitelist certain entities, rather than parsing them all. We really don't need ­ in chat, for example. – Jason C Mar 29 '17 at 22:08
  • 4
    I left my reply as a voice message: ▶ 🔘──────── 00:33 – Martin - マーチン Mar 30 '17 at 7:13
3

I can't answer your question but I threw together a quick userscript to add a couple characters I thought of to chat:

// ==UserScript==
// @name         Special characters in chat
// @namespace    http://stackexchange.com/users/305991
// @version      1
// @description  Add buttons for special characters to chat
// @author       Jason C
// @match        *://chat.meta.stackexchange.com/rooms/*
// @match        *://chat.stackexchange.com/rooms/*
// @match        *://chat.stackoverflow.com/rooms/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // From http://stackoverflow.com/a/11077016 (thanks!):
    function insertAtCursor(myField, myValue) {
        //IE support
        if (document.selection) {
            myField.focus();
            sel = document.selection.createRange();
            sel.text = myValue;
        }
        //MOZILLA and others
        else if (myField.selectionStart || myField.selectionStart == '0') {
            var startPos = myField.selectionStart;
            var endPos = myField.selectionEnd;
            myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
            myField.selectionStart = startPos + myValue.length;
            myField.selectionEnd = startPos + myValue.length;
        } else {
            myField.value += myValue;
        }
    }

    function insertContent (content) {
        var input = document.getElementById('input');
        insertAtCursor(input, content);
        input.focus();
    }

    function createButton (label, content) {
        var buttons = document.getElementById('chat-buttons');
        var button = document.createElement('button');
        //button.textContent = label;
        button.textContent = content; // I kind of like this as the label more.
        button.setAttribute('class', 'button');
        button.onclick = function () { insertContent(content); };
        buttons.appendChild(button);
        buttons.appendChild(document.createTextNode(" "));
    }

    // use fromCharCode instead of actual chars because there seems to be encoding
    // issues when transferring from github to tampermonkey.
    createButton('ndash', String.fromCharCode(8211));
    createButton('mdash', String.fromCharCode(8212));
    createButton('rarr', String.fromCharCode(8594));

})();

This will add some buttons to chat which you can click to insert the character into the text box:

enter image description here

I've only tested it on Chrome. If you've got a compelling reason for me to add other characters to the git version let me know. You can also customize the code pretty easily.

  • Nice. Porkchat has a handy list of characters beside "upload", the only downside of which is it not being scrollable. I was thinking you could make these another list-like thing? – Marshmallow Mar 30 '17 at 6:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .