Displaying the "Less Than" (<) symbol in our forum (and Dynamic Components)


#1

Continuing the discussion from Definition to the Left Instance to the Right - in Outliner:

@Moe,

The “Less Than” (LT) symbol causes the mini-editor in the forum software to start looking for allowed HTML tags. It keeps looking until it finds a “Greater Than” (GT) symbol. Once found, it looks at everything between them. If it’s allowed HTML, then it does the indicated action described. But if what it finds isn’t allowed HTML, it doesn’t display anything!

Here’s how I caused the word “indicated” above to appear as strikeout text:
<del>indicated</del>
That was an example of allowed HTML

What you want to do isn’t valid HTML, so we’ve got to find another way. I ran into this in another context (wanting to embed “<” in the description attribute of a Dynamic Component). The solution is use HTML Entities. For oddball characters like £ (if you have only $ on your keyboard), ±, ®, and lots more - as well as the LT symbol, they are how you can display symbols you can’t type - and get around the HTML display rules of the editor. Here’s how I did symbols I’ve already used:
&pound; <-- gave me the sign for the UK monetary unit &plusmn; <-- gave me the plus/minus &reg; <-- gave me the Registered Trademark symbol &lt; <-- gave me the Less Than sign
There are a number of reference pages that list these, just Google “html entities”.

What I’ve shown above is the “short” form - using mnemonics instead of the actual symbol. There is also a “long” form which isn’t mnemonic:
&#163; -- the UK Pound &#177; -- the plus/minus &#174; -- the Registered Trademark &#060; -- the Less Than
Note: ALL of the above cases, mnemonic or not, begin with an Ampersand ("&") and end with a semicolon (";")! Many people when first trying to use these omit the semicolon.

As far as I know, within the forum editor, the mnemonic forms work well, and are much easier to remember. So, your workaround for the Outliner list could have appeared as:
Right Back <Leg>
by entering is as
Right Back &lt;Leg>

So why do I even mention the non-mnemonic? It turns out that the editor for Dynamic Component Attributes has a weird quirk: If you enter the mnemonic form, it replaces it with the actual character. It displays correctly in the Component Options box. But the NEXT time you edit it, it tries to interpret is as HTML and suppresses it (unless it is allowed, valid HTML)! However, if you use the non-mnemonic form, it keeps it as is, and only changes it to the desired character when displayed in the Component Options box. That’s the context where I first learned the HTML entities trick, so I tend to use the non-mnemonic form, even in places the mnemonic form works as expected!


#2

Thanks for the info @sjdorst. I will make sure to use HTML Entities the next time.


#3

You could I think also enter the character between backticks (`) or even the whole text from Outliner.

For the whole text, even better to use three backticks followed immediately by text on a new line, then your text that you don’t was to have mangled, then on a new line after that, three more backticks


#4

The <backticks> work but produce a highlight.

The <HTML Entities> are pure.


#5

We used to be able to escape the less than and the greater than characters, within forum text, like this: ( \< and \> ). But escaping these characters is not supposed to work when the Discourse engine switches over to the CommonMark render library.

I know I’ve used these characters escaped many times in the past here. I hope that there is a search and replace feature that replaces my escaped situations with the proper character named entity notation.


See also: meta.discourse.org: Rendering text between < and >


#6

The same quirk applies to the description and title in the 3D warehouse, when typing directly in the edit fields you’re ok, but when managing content by CSV for a featured catalog, HTML -tags are dismissed.


#7

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.