Joplin formats code

for (i = 1; i <= 5; i++) {
  for (sp = 1; sp <= 5 - i; sp++) {
    document.write("&nbsp;&nbsp;");
  }
  for (j = i; j >= 1; j--) {
    document.write(j);
  }
  document.write("<br>");
}

This is the code I want to paste from VS code. I copy it, paste it in joplin and do Ctrl+`.
But this is how it formats the code. It's weird and dirty.

image

How to fix this issue?

Have you told Joplin what language it is?
The highlighting can't be copied across, the syntax is evaluated by codemirror and highlight.js on the fly by them guessing what language it is unless you tell it explicitly.

In the Markdown editor you can put it on the backticks (e.g

```js
your code here

or if you are using the richtext editor you can double click the code block and add it there.

2 Likes

No I've not told language which. As I said I paste code then select it and do Ctrl `...It formats it as code but such output comes which is horrible.

giving js works. Is there a way to make that appear automatically? I'm only learning js atm.

Not that I know of, usually it is pretty good at guessing but I always specify which language to make sure.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.