Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra new line inserted in markdown code block #7707

Closed
morremeyer opened this issue Aug 10, 2017 · 7 comments · Fixed by RocketChat/fuselage#537 or #23232
Closed

Extra new line inserted in markdown code block #7707

morremeyer opened this issue Aug 10, 2017 · 7 comments · Fixed by RocketChat/fuselage#537 or #23232

Comments

@morremeyer
Copy link

Description:

Until recent versions (I don't remember which one, sorry), code markup could be done as follows:

```
Text
```

which displayed as

Text

This behviour changed, as

```
Text
```

now displays as


Text

and you need

```Text
```

for

Text

This is really annoying as all other markdown implementations (at least known to me), e.g. GitHubs own ignore that newline after the ```.

Maybe this need discussion, I'm not sure of that.

Server Setup Information:

  • Version of Rocket.Chat Server: 0.57.2
  • Operating System: Mac OS Sierra 10.12.6
  • Deployment Method(snap/docker/tar/etc): unknown
  • Number of Running Instances: 1
  • DB Replicaset Oplog: unknown
  • Local Version: 2.8.0

Steps to Reproduce:

  1. Paste one of the above examples in your Rocket.Chat
  2. See the described behaviour

Expected behavior:

No change in behaviour the following should work as it did earlier:

```
Text
```

which displayed as

Text

Actual behavior:

It works as follows:

```Text
```

for

Text
@fnkr
Copy link

fnkr commented Sep 19, 2017

CommonMark also say's it should be rendered like

this

http://spec.commonmark.org/0.28/#fenced-code-blocks

@xenithorb
Copy link
Contributor

I think this should be re-categorized as a proper bug, and re-titled "Markdown code fencing produces extra newline"

@xenithorb
Copy link
Contributor

xenithorb commented Mar 7, 2018

Inner HTML for the pre's:

``` on same line:

<code class="code-colors hljs subunit"><span class="copyonly">```<br></span><span class="hljs-keyword">test
</span><span class="copyonly"><br>```</span></code>

With extra space:

<code class="code-colors hljs subunit"><span class="copyonly">```<br></span>
<span class="hljs-keyword">test
</span><span class="copyonly"><br>```</span></code>

So I'm guessing we either need to stop sending extra <br>s or we need to strip leading newlines from the input. Remember these are encased in <pre> tags, so the line breaks are going to render. The actual markup itself is identical minus the linefeed.

@morremeyer
Copy link
Author

@xenithorb I fully agree with that. I prefer the "stop sending extra <br> solution" as it looks cleaner to me.

@xenithorb
Copy link
Contributor

xenithorb commented Mar 7, 2018

  1. It only happens with the original markdown parser

  2. Because of that, I believe the bug is on this line: https://github.com/RocketChat/Rocket.Chat/blob/develop/packages/rocketchat-markdown/parser/original/code.js#L61
    I would fix it but I'm not good with JS, and I'm not certain what the team's goal here would be in a "proper fix"

    i.e. you could probably just remove the <br> in this span:

    <span class='copyonly'>\`\`\`<br></span>

@geekgonecrazy geekgonecrazy changed the title Roll back code markup changes Extra new line inserted in markdown code block Mar 8, 2018
@graywolf336
Copy link
Contributor

There was a pull request to fix this, but I can't find it now for some reason...

@xenithorb
Copy link
Contributor

@graywolf336 #8510 Found it

Perhaps triage #9754 to go along with this fix too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants