Numbered Lists + Code = Formatting Bug

@admins and @wendell There's a formatting issue with Posts using numbered lists and code tags

Creating a numbered list with source code formatted tags inbetween each item causes the numbering to restart at 1.

What I input:

1. String

```bash
script here
```
2. String

What happens:

  1. String

script here
  1. String

What I expect

  1. String
    script here (done using single ` tags)
  2. String

Other odd behaviour

Putting script tags inside script with another script block after normal content causes the first script block to not be closed and run across the content in the middle.

sudo rm -rf /
```funkylanguage

do more stuff
```

```

This Line not in script tags <- Script tags go right over this which is not inside the script tags.


```script
Other script code

What the text for that looks like:

Updated to include new observations

See this post for where I first discovered it:

I think that's because <pre> tags come before code blocks during markup usually. Issue with discourse, I don't think L1 can do anything about this. You'd be better off filing a bug report on the discourse github.

Yeah I gave It another test and It basically comes down to how browsers handle HTML and how Discourse converts it's own markup tags to HTML, as well as how it sanitizes input I guess.

Here's an example of how regular HTML behaves in a browser using HTML 'pre' tags.

https://www.w3schools.com/code/tryit.asp?filename=FESM1EOD3L7D

Then what I wrote below:

And the result as rendered on the forum:

Code
     <pre>
      More code

Heading

 Text in here

So likely there isn't much to be done about it anyhow.

My buddy @Goalkeeper noticed this before.

Ok so looking at the code that discourse generated It's clearly an issue with escaping nested tags as part of the input sanitization process. It's just not done correctly since it simply terminates on the next closing tag instead of the last aligned tag.

As for the

 ```

tags with numbers.

This is what happens:

It replaces them with pre tags in the output but places them inbetween the ordered list rather than inside the ordered list as list items. Which is actually possible to do with HTML:

https://jsfiddle.net/swrr37kx/