New lines in Markdown

I know DEVONthink uses the MultiMarkdown syntax, but all the same I’ve been struggling with the display of line endings in the preview.

My existing MD documents didn’t adhere to the MultiMarkdown specs of ending a line with two spaces, and displayed like A in the picture below:

But manually adding two spaces at the end of a line has consequences I don’t like (see under B). What I want is my docs to display like C.

Now that DT supports a global stylesheet (via Preferences > Media > Style Sheet) I realised I can achieve this with a bit of css. Simply adding

white-space: pre-line;

to the p selector does the trick.

I couldn’t find anything about this in the forum, so maybe this is useful to someone else as well.

Or did I miss something, and is there a better solution to this problem?

No, there isn’t a better solution - though there are likely other CSS options that could be explored.

Markdown and MultiMarkdown require the two spaces at the end. If your fix works for you, I’d say use it.

What is the reason code blocks display as one continuous line in DT, whether lines are terminated by spaces or not?

By code blocks I mean:

# Stuff
# Like this

Same thing in DT:
Screenshot 2023-02-11 at 22.28.03

They won’t display as one continuous line if you use fenced code blocks, like this (using three backticks to enclose the text):

```
The text
```

E.g.:

# Stuff
# Like this

Stephen

1 Like

You’re correct, thanks. I figured out what was going on, in case it helps someone:

I’m using a custom markdown CSS file and unfortunately DT & my main markdown editor don’t render in exactly the same way. Since I didn’t want inline code to wrap, I had put a white-space: nowrap there. Changed it to white-space: pre and both applications are happy.

Thank for confirming that it should work, it helped me locate the problem.

BTW, is it possible for DT to style differently the fenced code blocks and the inline code blocks? Many renderers do that I believe.

It’s all really down to you with the CSS you use, isn’t it?

1 Like

Of course, but I don’t know which CSS selectors to use in order to target both fenced and inline code independently in DT (I can’t inspect the rendered HTML to see class names).

Convert your MD to HTML in DT, open the HTML in your browser and use its developer tools to inspect the HTML. There you can also play around with CSS

2 Likes

Of course. Should’ve thought of it but I never use HTML documents in DT and I almost forgot they existed. Thanks a lot.

1 Like

DEVONthink uses MultiMarkdown.