# 大于和小于的意外格式

**URL:** https://meta.discourse.org/t/unexpected-formatting-of-greater-than-and-less-than/44479
**Category:** Support
**Created:** [2016年五月19日 07:21 UTC](https://meta.discourse.org/t/unexpected-formatting-of-greater-than-and-less-than/44479 "2016-05-19T07:21:51Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![GaurangTandon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gaurangtandon/32/52384_2.png) [@GaurangTandon](https://meta.discourse.org/u/GaurangTandon)
#### Post date: [2016年五月19日 07:21 UTC](https://meta.discourse.org/t/unexpected-formatting-of-greater-than-and-less-than/44479/1 "2016-05-19T07:21:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2016年五月19日 07:25 UTC](https://meta.discourse.org/t/unexpected-formatting-of-greater-than-and-less-than/44479/2 "2016-05-19T07:25:50Z")

</div>

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”

---

<div class="post-metadata">

### Author: ![lrossouw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lrossouw/32/121275_2.png) [@lrossouw](https://meta.discourse.org/u/lrossouw)
#### Post date: [2016年五月19日 07:49 UTC](https://meta.discourse.org/t/unexpected-formatting-of-greater-than-and-less-than/44479/3 "2016-05-19T07:49:09Z")

</div>

`<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`.

---

<div class="post-metadata">

### Author: ![GaurangTandon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gaurangtandon/32/52384_2.png) [@GaurangTandon](https://meta.discourse.org/u/GaurangTandon)
#### Post date: [2016年五月19日 08:27 UTC](https://meta.discourse.org/t/unexpected-formatting-of-greater-than-and-less-than/44479/4 "2016-05-19T08:27:09Z")

</div>

Haha, now I seem very stupid 😛 Thanks both of you for your explanation 😃

---

<div class="post-metadata">

### Author: ![GaurangTandon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gaurangtandon/32/52384_2.png) [@GaurangTandon](https://meta.discourse.org/u/GaurangTandon)
#### Post date: [2016年五月19日 10:36 UTC](https://meta.discourse.org/t/unexpected-formatting-of-greater-than-and-less-than/44479/5 "2016-05-19T10:36:54Z")

</div>

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>`.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2016年五月19日 18:48 UTC](https://meta.discourse.org/t/unexpected-formatting-of-greater-than-and-less-than/44479/6 "2016-05-19T18:48:12Z")

</div>

> [@GaurangTandon](#):
>
> But shouldn’t these HTML tags be interpreted only when they are written like \<b\> and not when \<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

```plaintext
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.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2024年六月8日 12:45 UTC](https://meta.discourse.org/t/unexpected-formatting-of-greater-than-and-less-than/44479/7 "2024-06-08T12:45:42Z")

</div>

此主题已在 2942 天后自动关闭。不再允许回复。
