Markdown code blocks are not rendered with newlines #276

Closed
mbruzek opened this Issue May 23, 2016 · 9 comments

Comments

Projects
None yet
8 participants

mbruzek commented May 23, 2016

In my published charm (https://jujucharms.com/u/mbruzek/kubernetes/trusty/5) the README is not getting rendered correctly on the Charm Store.

The readme markdown starts and ends a code a block with three backticks:

juju deploy trusty/etcd
juju deploy local:trusty/kubernetes
juju add-relation kubernetes etcd

This block gets rendered without any newlines as:

juju deploy trusty/etcd juju deploy local:trusty/kubernetes juju add-relation kubernetes etcd

We should preserve the newlines in code blocks or I suspect you will have many other people finding this a problem.

jrwren commented May 24, 2016

Also, sometimes the blocks are rendered with the ``` being displayed.

https://jujucharms.com/u/evarlast/parse-server/trusty/0 See the Using it section.

Linking this with #228 as we've had some issues with the markdown parser, and I still feel that GFMD would solve a lot of these issues (its territory well traveled)

arosales commented Jun 6, 2016

We are seeing this in a few places now, any ideas on how we can fix this?

-thanks,
Antonio

@anthonydillon anthonydillon self-assigned this Jun 7, 2016

Member

anthonydillon commented Jun 7, 2016

Our supported markdown syntax for code blocks and code are as follows.

To produce a code block, simply indent every line of the block by at least 4 spaces or 1 tab. For example, given this input:

This is a normal paragraph:

    This is a code block.

Will generate:

<p>This is a normal paragraph:</p>

<pre><code>This is a code block.
</code></pre> 

To include a literal backtick character within a code span, you can use multiple backticks as the opening and closing delimiters:

There is a literal backtick (`) here.

Will produce this:

<p><code>There is a literal backtick (`) here.</code></p>

The code blocks need to be wrapped in a pre tag to show new lines so the above juju commands should be tabbed instead of ticked. We should document this syntax for charmers to reference or could move to GitHub style markdown.

mbruzek commented Jun 7, 2016

Thanks @anthonydillon for comment. I think we must respect new lines with in the multiple backtick blocks. The reason I opened this bug is because I believe the Canonical process is not displaying/rendering the markdown correctly.

Markdown source:
screenshot from 2016-06-07 10-32-48

File rendered on the Charm Store:
screenshot from 2016-06-07 10-32-38

In the README.md I expected to see the different commands on their own line and they have all newlines (view source here) removed because this is what I saw on Markdown preview tools when I was writing the file.

The three backticks allow authors to specify which language the code block is, so syntax highlighting works better for many cases where we want to display code.

I can fix my README.md to the other code block style, but the charm store has many different authors who may have used the three backtick method (which is completely valid in markdown). We must display these blocks as the authors expected, and can not ask them to re-write their files using the other block style.

mbruzek commented Jun 7, 2016

I believe the way we render this will be a problem for anyone who puts code in the three backtick code blocks. Example: https://gist.github.com/anonymous/f98f024db6e9bab0732bb705e2a630db
Click on RAW to view the Markdown source.

We have README.md files which render correctly on github, but squash newlines within the triple backtick code blocks on the charm store. Is there an ETA for resolving this, or should we be updating mds in a special way so that the cham store will also render them as expected?

@frankban frankban added the bug label Jun 10, 2016

@frankban frankban added this to the next milestone Jun 10, 2016

@anthonydillon anthonydillon removed their assignment Sep 17, 2016

Member

frankban commented Mar 3, 2017

This is done, we now support github markdown extensions.

@frankban frankban closed this Mar 3, 2017

Woot, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment