remark
remark copied to clipboard
code blocks not rendered if newlines present
Consider the following slide. Note that the code blocks do not have a newline separating them from the bullet-point lines. This is intentional in order to achieve bullet-indented code blocks and this works fine. However, if you add a newline inside one of the codeblocks, to separate lines 'node1' and 'node2', the codeblock is no longer recognized.
Now look at this slide. You'll notice there are now newlines between the codeblocks and a newline within the codeblock. This is closer to the intended result, however, the codeblocks are no longer "indented" with the bullets as they were before.
How can I achieve the result of having "intended" codeblocks as in slide 1 but also support newlines like slide 2?
My apologies for using pastebin. github won't let you do codeblock within codeblock.
You simply need to indent your code block. Eg:
- bullet point
- bullet point (indent) ```sql (indent) your code block... (indent) ```
- bullet point
@joel-porquet thanks. I'll give it a try.
@joel-porquet Gave it a try as you suggested. Your solution, unfortunately, adds extra linebreaks in the rendered HTML.
Where? Can you copy the HTML output maybe and point to where there shouldn't be linebreaks?
Take a look at these screenshots. You can see in the last screenshot, I added space in the remark code along with your suggestion of indenting all the blocks. You'll notice in the rendered HTML, there are additional newlines above and below the codeblocks.
Well, it just means that you can't add new lines in between your bullets and your codeblocks in the source file.
The reason is that each empty line ends the current paragraph and starts a new one.
But if you're able to obtain a HTML result that looks like what you want (which seems to be the case in your first screenshot), then I don't see the issue (apart from the fact that your source code might look a bit packed, but well...) :)
Some more examples. The 3rd screenshot demonstrates the main issue of line breaks within codeblocks. If I indent the code block 2 spaces inward, then extra linebreaks are added to the rendered HTML as seen in screenshot 1. Screenshot 2 demonstrates proper handling of linebreaks within the codeblocks, but the codeblocks are no longer indented with the bullet points in the rendered html.
This is the result I'm after. But you'll notice I had to remove the linebreak within the codeblock in order to get the right rendered HTML. So, this is a bug.
It seems like adding the newline within the codeblock transform the second bullet point into a paragraph for some reason. I just tried on a simple example, and I can reproduce the "issue" (if it's really one - AFAIK, it could be like that by design).
First code:
* my first bullet
* my second bullet
```sql
-- This is a comment
-- This is a comment too
node3# iptables -A INPUT; \
iptables -A OUTPUT; \
iptables -A OUTPUT -j DROP;
```
* my last bullet point
The generated HTML code is:
<ul>
<li>my first bullet</li>
<li>my second bullet<pre><code class="sql hljs remark-code"><div class="remark-code-line"><span class="hljs-comment">-- Pay attention to the indentation</span></div><div class="remark-code-line"><span class="hljs-comment">-- This is a comment</span></div><div class="remark-code-line">node3# iptables -A INPUT; \</div><div class="remark-code-line"> iptables -A OUTPUT; \</div><div class="remark-code-line"> iptables -A OUTPUT -j <span class="hljs-keyword">DROP</span>;</div></code></pre>
</li>
<li>my last bullet point</li>
</ul>
Now, when adding a new line in the codeblock:
* my first bullet
* my second bullet
```sql
-- This is a comment
-- This is a comment too
node3# iptables -A INPUT; \
iptables -A OUTPUT; \
iptables -A OUTPUT -j DROP;
```
* my last bullet point
The generated HTML is (notice the <p></p>
around the second bullet):
<ul>
<li>my first bullet</li>
<li><p>my second bullet</p>
<pre><code class="sql hljs remark-code"><div class="remark-code-line"><span class="hljs-comment">-- Pay attention to the indentation</span></div><div class="remark-code-line"><span class="hljs-comment">-- This is a comment</span></div><div class="remark-code-line"></div><div class="remark-code-line">node3# iptables -A INPUT; \</div><div class="remark-code-line"> iptables -A OUTPUT; \</div><div class="remark-code-line"> iptables -A OUTPUT -j <span class="hljs-keyword">DROP</span>;</div></code></pre>
</li>
<li>my last bullet point</li>
</ul>
Maybe someone else can give their opinion, as I don't know if it's an expected behavior.