obsidian-custom-js icon indicating copy to clipboard operation
obsidian-custom-js copied to clipboard

feature request: support codeblocks for syntax highlighting

Open vitaly opened this issue 4 years ago • 2 comments

right now I can either use .js files, which can't be edited directly in obsidian, or use .md files with js code in them, which do not have proper syntax highlighting.

it would be nice if it was possible to use .md files with frontmatter, and have the actual code inside a js codeblocks:

---
created: 2001-01-01
tags: snippet, dataview
type: customjs
---
```javascript
class Foo {
   ...
}
```

```javascript
class Bar {
   ...
}
```

this format should be easy to detect by checking for frontmatter.

vitaly avatar Oct 16 '21 19:10 vitaly

I like this idea, I'll take a look at it when I get a chance

saml-dev avatar Oct 18 '21 13:10 saml-dev

There's a plugin that lets you view js files within Obsidian: https://github.com/dbarenholz/obsidian-plaintext It has syntax highlighting in the works too: https://github.com/dbarenholz/obsidian-plaintext/issues/10

NomarCub avatar Oct 12 '22 17:10 NomarCub

There is also a plugin that adds syntax highlights to code blocks. Won't that fix your problem?

danielo515 avatar Aug 31 '23 11:08 danielo515

This issue was opened almost 2 years ago. Sounds like there are workarounds now with other plugins, which makes more sense than building this into customjs.

saml-dev avatar Sep 02 '23 02:09 saml-dev

There's no workaround that I know of, the one I linked is still open. If you know any, please share it, @saml-dev.

NomarCub avatar Sep 02 '23 04:09 NomarCub

There's no workaround that I know of, the one I linked is still open. If you know any, please share it, @saml-dev.

https://github.com/deathau/cm-editor-syntax-highlight-obsidian

danielo515 avatar Sep 02 '23 09:09 danielo515

That plugin hasn't been updated for over 2.5 years and judging by its GitHub issues, not really functional.

NomarCub avatar Sep 02 '23 09:09 NomarCub

That plugin hasn't been updated for over 2.5 years and judging by its GitHub issues, not really functional.

Not all plugins need to be updated on a weekly basis. I am using that plugin, and it is perfectly functional in bot edit and preview modes:

image image

What else do you want?

danielo515 avatar Sep 02 '23 12:09 danielo515