CenterForOpenScience / osf.io

Facilitating Open Science
https://osf.io
Apache License 2.0
666 stars 327 forks source link

Markdown no newlines in codeblock #7308

Open jpkeith4 opened 7 years ago

jpkeith4 commented 7 years ago

No matter what I try I cannot seem to get code blocks to show newlines. Additionally, it only seems possible to specify newlines in OSF's markdown renderer in general by adding 2 spaces to the end of a line, but even that doesn't work inside codeblocks.

The block displays fine of course if it contains no newlines. However something like this: ``` line 1
line 2
```

Will show up as: line 1 line 2

I've tried searching for different types of markdown syntax and trying just about every variant I can think of, and the block simply will not display newlines.

I can work around the issue by just making every single line of code its own block and adding 2 spaces to the end of each to achieve a newline, but this is rather tedious and looks very ugly.

If this is by design is there any chance it could be changed? There is already a feature for single line blocks using single quotes. In markdown triple quotes is supposed to be reserved for blocks that might contain newlines.

TomBaxter commented 7 years ago

Hello, sorry for the confusion. Here a link to the specific Doc.

In short, indent each line of the block by four spaces.

     This is
     a three
     line code block

This
is
not
jpkeith4 commented 7 years ago

This doesn't work in the OSF file display. They just show up like normal lines of text. I also tried double and triple spacing.

TomBaxter commented 7 years ago

Sorry this isn't working for you. Frustrating. Let me make sure I'm on the same page.

You are editing a file by the name something.md or something.markdown in the editor in the Files tab of your project? If so that should work. Please try creating and uploading a file called myfile.md with just the following contents and see if it renders as you want.

Line One: Four spaces followed by a word and a carriage return Line Two: Four spaces followed by a word

No quotes or ticks

jpkeith4 commented 7 years ago

Ok that simple file works, and after trying a few other things I think the issue is preceding the block by a bulleted line, or a non-bulleted line that is itself preceded by one.

For example, this doesn't work:

- Bulleted line

    this code block
    doesn't work

But:

Non-bulleted line

    this code block
    works

and also, strangely enough:

- Bulleted line
Non-bulleted line

    this code block
    also doesn't work
TomBaxter commented 7 years ago

I see what you mean. Yeah, that sucks. After reading a little further in the Markdown Doc I see that line breaks are signified by two or more trailing spaces at the end of a line. I couldn't get it to work with the Bullet line but in your third example if you add two spaces to the end of "Non-bulleted line " the code block renders correctly. Completely intuitive right? ;( I know that's not much consolation, but maybe it will help you out.

jpkeith4 commented 7 years ago

Well I still thank you for the help. I'll just have to figure out a way to change some of my documentations to use a non-bulleted line before a block and somehow still preserve their flow I guess.

TomBaxter commented 7 years ago

I'm still pursuing this a little further. We are using the Python standard Library Markdown to render those files, and I'm looking there for answers as well. Also, I know that we are looking to standardize/change our Markdown both javascript and Python, so there may be improvements in the future.

tcerven-emory commented 4 years ago

For me it turns out that it was trying to render the markdown. It didn't like when there was no space between the heading tags "#" and the text. For instance when I had coded this line:

#Heading1

it rendered

#Heading1

instead of

Heading

When I inserted a space

# Heading1

it rendered correctly.

Also, the BB renderer didn't like entities such as   or ‑