Viewing code files in Vault with highlighting by file extension


I keep a number of useful demonstration code files using R, julia, python, etc. in my vault and I would like to be able to view them in obsidian with the same code formatting that Obsidian uses in its embedded code blocks.

The thing I’m interested in

For reference, say that I have a normal note in my vault with the lines:


Here is how you can create a function in R:

# a demonstration of how to build a function in R
f <- function(x, y) { # open curly brackets
return(x + y) # remember to return something
} # don't forget to close the curly brackets
f(1, 2) # gives 3


Because I have put " ```r " at the start of the code block, it will format the code appropriately for R, recognising functions, comments, etc.

If I press “ctrl + shift + i”, I can view the note elements and see that Obsidian is wrapping this block in a class “HyperMD-codeblock”, which, presumably gives it the nice formatting.


Is there a way, if I have a .R file inside my vault, to allow me to view that file using the same “HyperMD” rendering that I’m doing in-note?

There is a package by MeepTech that allows you to render files by their extension, which requires using different “in-app views” to manage different file types. Can I create an in-app view that renders as code (not markdown, as I don’t want to have to wrap all files in " ``` ") and to include the nice formatting that seemed to come from HyperMD?

I don’t know any Java/TypeScript so I’m at a loss for how to approach this problem.

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