Canned reply insertion truncates trailing space(s)


Just created a new canned reply and discovered that the trailing space which I had intentionally added is removed when the canned reply is inserted into the draft post.

In this specific instance, I was creating a prefix for items I create a lot in a bullet-pointed list, an example of the use case is;

See also;

* GameDev<span>.</span>tv - Community : 

After the colon there is a space character because I would then add the topic URL from the community site, which Discourse rather nicely then turns into the topic title text, thank you :slight_smile:

I use the same approach for URLs that are external to our community also, for example you might see this;

See also;

* Microsoft Docs : [Access Modifiers (C# Reference)](
* GameDev<span>.</span>tv - Community : [Topic title of previously asked question](

I didn’t set this as a bug, as I’m sure in many cases it would make sense to trim the trailing spaces, that would be indeed tidy. But in the scenarios where you want the trailing space, it’s annoying.

Could the functionality be tweaked so that whatever you enter as a Canned Reply is exactly what you get? This would then put the onus on those messy types who leave trailing spaces to tidy them up themselves (you know who you are!) but for the rest of us, tidy-types, who choose when to add them and when not to, we would be perfectly served :slight_smile:

And yes, I did just create a topic about a Space character - please be gentle…

1 Like

Why not add an extra character after the trailing spaces, so the spaces are preserved? Then delete the extra character after inserting the canned reply.


I haven’t tested, but I think &nbsp; could work. Depending on where the trim happens it may need an escape or two so it won’t get trimmed. eg. \&nbsp; or \\&nbsp;


I could, but I suppose if I was to stand on my soap box I’d say, “but should I really have to?”.

Adding another character to then delete each time wouldn’t be much of a saving of time/removal of frustration over having to add a space each time :slight_smile:

Is there a reason that the canned replies are not just accepted as-is (as-are?) when created rather than being tidied up? The only one I could think of would be that the same code/process is used for posts in general and that perhaps the tidy up process applies to posts in general.

I’ll give it a try now, I’m a little hesitant to pop the HTML entity in though, mainly from a readability perspective when looking at the canned replies in edit mode, I don’t really like having to add the <span> tag thing I’m doing in that example either but I wanted to prevent the auto-hyperlinking and that was the only way to achieve it (I think).

Just as an update, I’ve tried adding the &nbsp; and yes, it would work - although when viewing the post it does mean you have the see the HTML in the draft post which, for me at least, isn’t ideal.

Just one other minor thing, when I went back in to edit the canned reply to add the &nbsp; characters, the previously added trailing space was actually there. It would seem that the truncation doesn’t happen when you save the canned reply (which would make sense) but when you select it and it pops it into the draft post (which doesn’t make sense, in my opinion).

So, maybe it’s just the little bit of code which inserts the canned reply into the draft post that needs the tweak?

/hoping :slight_smile: