This plugin for Obsidian allows you to run JavaScript from within your notes using special code blocks.
Start by creating a code block with js-engine
as the code block language.
Inside the code block you can write what ever JavaScript code that you want.
The plugin will run the JavaScript and render the returned value in place of the code block.
## This is a Note in Obsidian
```js-engine
return engine.markdown.create('*test*');
```
Docs are available here.
let markdownBuilder = engine.markdown.createBuilder();
markdownBuilder.createHeading(2, 'Test Heading');
markdownBuilder.createParagraph('This is a test paragraph.');
markdownBuilder.createHeading(3, 'This is a sub heading');
markdownBuilder.createHeading(4, 'This is a sub sub heading');
markdownBuilder.createParagraph('This is another test paragraph.');
return markdownBuilder;
This is a test paragraph.
This is another test paragraph.
let str = '*test*';
return str;
let str = '*test*';
return engine.markdown.create(str);
The top example renders the string as plain text and the second one renders the text as markdown.
*test*
test
let lib = await engine.importJs('lib.js');
return lib.getGreeting();
With a file named lib.js
in the root of the vault.
export function getGreeting() {
return 'Hello!';
}
Hello!