Unexpected formatting of greater than and less than


(Gaurang Tandon) #1

The is the actual text in the actual way it was written:

Actual text:


if a<b
  print "a is less than b!"
elsif b<a
  print "b is less than a"

Can someone please explain why the following result is being produced by the above text? How does the bold text and the blue link text come into existence? If it a fault with Discourse markdown parser, please fix it. Thanks! :smiley:


Result produced:

if a<b
print "a is less than b!"
elsif b<a
print “b is less than a”


Anything below that text also appears weird :confused: even after a horizontal rule is put


(Mittineague) #2

It is blue because you did not escape the left angle or put the code in a code block.

“left angle a” is interpreted as the beginning of a link.

Link color is blue.

How you did it in your “Actual text” is the proper way to post code.

Or I suppose you could use spaces

if a < b
print "a is less than b!"
elseif b < a
print “b is less than a”


(Louis Rossouw) #3

<b is the start of a bold tag in html.
<a is the start of a link tag.

That is why it’s happening. You get bold from the <b and blue from the <a.


(Gaurang Tandon) #4

Haha, now I seem very stupid :stuck_out_tongue: Thanks both of you for your explanation :smiley:


(Gaurang Tandon) #5

But shouldn’t these HTML tags be interpreted only when they are written like <b> and not when <b?

The above text was made bold even when there was just <b and not <b>.


(Mittineague) #6

Similarly, only when <a> and not when <a ?

Parsing characters can be done, and indeed already is.

But there is a wide range between “don’t parse anything” and “parse everything that could possibly be there”.

for a contrived example

if(count<a){
 if((amount=="all")&&(time>24)){

you wouldn’t want to get a link like <a){ if((amount=="all")&&(time>

In other words, regular expressions and conditional testing could be used, but having enough code in place to deal with everything would be extreme.

What is most commonly done is what is done here. a compromise. Be it bbCode, Handlebars, HTML MarkDown, i.e.

As long as the text is entered in a certain format it will be parsed.

When something is not in a certain format when it should be, and when it shouldn’t be but is, that’s when there’s a problem.