Multi-line code blocks

Great suggestion, only my results vary from yours:

See that blank link at the start of the comment, it’s where the ``` is at. You want it that way so I can more easily clip this code into a file.

It would be cool if

  • Devs implemented a code-mode like number-list mode, where any bullet items that are under Code mode would be mono-spaced.
  • Further, if a Paste-code function would magically recognize indentation (spaces or tabs) and format appropriately.
  • And further if Copy of multiple lines would also offer a plain-text with tab indentation. (from DL to source-code editor. This last bit would be equally good from DL to Wordprocessor.)
1 Like

You can also select all of the code (ctrl/cmd+A) and then use (ctrl/cmd+`) to format the code.

This requires an additional tool for doing the formatting, right?

To have proper code syntax highlighting based on the programming language, yes. That’s assuming one is available. The backticks simply convert the text to monospaced.

Oh, monospace is my default font anyway :slight_smile:

1 Like

As I understand it, the practice of using three backticks to start/stop a code block exists so that the code block can include backticks without terminating the block.

Based on my tinkering with dynalist, it looks like the three consequtive backticks just do this:

prose goes here
[start block][stop block][start block]
code goes here
[stop block][start block][stop_block]
more prose here

That is, if your code contains a backtick, it will terminate the formatting. As it stands, you might as well just use a single backtick.

What would be nice is if three backticks start a code block that can only be terminated with another three backticks, then you could do this:

```
echo first file: `ls | head -n 1`
```

…and the backticks in the code block wouldn’t interfere (markdown does it this way, so does slack). Ideally the first empty newline would also be ignored in this case, which makes it easy to triple-click-highlight the whole line and not also pick up the formatting indicator.

Additionally, it would be cool if the code blocks appeared in <pre> tags when exporting to html.

3 Likes

Using three backticks is fine, however, It will delete all indentation, I don’t want to manually indent every line in dynalist.
Any suggestions or advices? Thanks in advance.

1 Like

Guys, the only thing I miss in dynalist is multi-line code block out of the box.

5 Likes

Same here. Dynalist is the perfect match for my workflow but I need standalone multi-line code blocks with syntax highlighting. It shouldn’t be hard to implement. Please!

3 Likes

Ahem - yet another use case that could be easily solved by incorporating a comprehensive third-party markdown renderer.

1 Like

thanks, this markdown code block with triple backticks works!

Hi all! Does this work now? For me hitting enter or pasting something multiline always creates new item - either with triple backticks or without

a) Use shift-enter to add a note. you can use multiple lines in the note.

b) Or, use ctrl+shift+enter to add more lines to the item without advancing to the next bullet

c) If there’s a way to paste multiple lines into a single bullet, I don’t know it.

1 Like

I copy multiple lines into a single bullet by first pasting what I’m copying into a note (shift-enter). When I’m adding code, I put the triple-tick marks in front of the first line and after the last line. If you just want plain text in multiple lines, just don’t use the tick marks. I haven’t figured out a way to directly paste multiple lines into a single bullet.

Thanks you @Alan, @WebAlstrom ! ctrl-shift-enter is what I was looking for :+1:

By any chance, does the indentation change from tabs to spaces when saved as a snippet on Dynalist?

Asking because I never use spaces but pasted snippets have spaces. When I use tab, the IDE tells me I can’t mix tabs with spaces.

Reminds me of that episode in Silicon Valley :sweat_smile:

No. Not for me.

I pasted

test
	test
		test
			test
test

into a note, then clicked elsewhere to render it, then clicked the copy button on the right corner. I then pasted it back in text editor. It still has tabs.

1 Like

I’ll update once I solve this mystery :man_shrugging:

I am also using the AHK keyword, but there is no highlighting taking place.
My attempt looks something like this:
image

What could possibly be going wrong?

To paste multiple lines into a bullet-point, the simple way I use is:

  1. Paste it in the note below another bullet-point.
  2. Copy the note (Ctrl+A , Ctrl + C)
  3. Paste it in a new bullet. (Ctrl + V)
1 Like