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!
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 even after a horizontal rule is put
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â
3 Likes
lrossouw
(Louis Rossouw)
May 19, 2016, 7:49am
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
.
5 Likes
Haha, now I seem very stupid Thanks both of you for your explanation
2 Likes
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>
.
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.
3 Likes