gnab / remark

A simple, in-browser, markdown-driven slideshow tool.
http://remarkjs.com
MIT License
12.68k stars 856 forks source link

Two unwanted lines at the end of each code block #617

Open josephernest opened 4 years ago

josephernest commented 4 years ago

First of all, congrats for this wonderful project!

Live demo of the issue: (offline)

image

When creating code blocks with 4-space indent...

<html>
<body>
<textarea id="source">
This is a block of code:

    import test
    hello.hello()

This is a single line:

    print('hello')

**Why the two final extra lines in each block of code?**
</textarea>
<script src="https://remarkjs.com/downloads/remark-latest.min.js"></script>
<script>remark.create({highlightLanguage: 'python'});</script>
</body>
</html>

... there are two extra lines in each block of code.
How to make that, by default, they don't appear?


PS: indeed the rendered HTML contains them:

<code class="python hljs remark-code">
<div class="remark-code-line"><span class="hljs-keyword">import</span> test</div>
<div class="remark-code-line">hello.hello()</div>
<div class="remark-code-line"></div>  <!-- why this line ? -->
<div class="remark-code-line"></div>  <!-- why this line ? -->
</code>

PS2: here is how the same Markdown renders for example on StackOverflow:

image

mschilli87 commented 4 years ago

@josephernest: Thank you for providing more and more information but please consider useing the edit function to modify your original post instead of spamming over 200 users with a notification every few hours. :wink:

josephernest commented 4 years ago

@josephernest: Thank you for providing more and more information but please consider useing the edit function to modify your original post instead of spamming over 200 users with a notification every few hours.

Thanks for your comment, I deleted the unwanted messages, and merged everything into 1 post, it is better indeed. But, btw your message and this actuel answer here also generated noise notifications ;)

dvberkel commented 4 years ago

@josephernest I can imagine that the two blank lines is annoying. It probably depends on the markdown parser we are using, so we will have to take a look if we can change that easily.

In the mean time, would it be okay for you to fence your code blocks with triple back-ticks?

josephernest commented 4 years ago

Thanks for your answer @dvberkel, and once again congrats for this wonderful project. Yes I'll use this in the meantime

```
code
```

for the pages where the two extra lines cause a page-height overflow.

PS: which parser do you use?

dvberkel commented 4 years ago

I can't take credit for this wonderful project. @gnab started it and brought it into fruition. I am just here to give back to the community.

PS: which parser do you use?

There is a custom parser that splits out various slides and consumes the properties. We currently use markedjs as the markdown parser, albeit an old version.

Maintenance is picking up, so you can expect things to picked up sooner.

josephernest commented 4 years ago

Thanks for your answer @dvberkel. I just tried with markedjs, [here is a live demo](https://marked.js.org/demo/?text=This%20is%20a%20block%20of%20code%3A%0A%0A%20%20%20%20import%20test%0A%20%20%20%20hello.hello()%0A%0AThis%20is%20a%20single%20line%3A%0A%0A%20%20%20%20print(%27hello%27)%0A%0A**Why%20the%20two%20final%20extra%20lines%20in%20each%20block%20of%20code%3F**&options=%7B%0A%20%22baseUrl%22%3A%20null%2C%0A%20%22breaks%22%3A%20false%2C%0A%20%22gfm%22%3A%20true%2C%0A%20%22headerIds%22%3A%20true%2C%0A%20%22headerPrefix%22%3A%20%22%22%2C%0A%20%22highlight%22%3A%20null%2C%0A%20%22langPrefix%22%3A%20%22language-%22%2C%0A%20%22mangle%22%3A%20true%2C%0A%20%22pedantic%22%3A%20false%2C%0A%20%22sanitize%22%3A%20false%2C%0A%20%22sanitizer%22%3A%20null%2C%0A%20%22silent%22%3A%20false%2C%0A%20%22smartLists%22%3A%20false%2C%0A%20%22smartypants%22%3A%20false%2C%0A%20%22xhtml%22%3A%20false%0A%7D&version=master), the unwanted lines are not present here.

Is there a custom rule that adds them in remarkjs @gnab?

dvberkel commented 4 years ago

@josephernest The live demo you are linking to is using the master version of markedjs, but it has the same behavior when you time-travel to version 0.3.19, the version that remark is using up to version 0.15.

I can imagine that it is an annoying issue for you, but you will have to sit tight. A new group of maintainers is trying to get things into shape and address the issue that are reported. When we have settled the issue we will notify you via this issue. In the meantime, there is a viable workaround.