obsidian-execute-code
obsidian-execute-code copied to clipboard
Install problems only at first use.
I use this code (Win10) with line numbers, Python 3.8 path: C:\Python38\python.exe, dark theme:
def hello(name):
print(name)
if __name__ == "__main__":
hello("Eve")
When changing from ITS Theme to Standard Obsidian Theme, there is no "copy" and "run"-Button anymore. Closing and restarting the application does not solve the problem. But when I wait (~1-2 minutes?), the buttons "copy" and "run" appear again (hovering nesseccary). After this, I can use the plugin without problems: The buttons don't dissapear anymore. (The "clear" button is always visible.)
At least in these themes, the buttons have to hover with the mouse to see them: 80s Neon Obsidian Nord Dracula for Obsidian Things Night Owl Deep Work (The copy button gets colored, the run button not.) Blue Topaz, Obsidianite (only the run button can be made visible via hover; the copy button is an icon, not well positioned)
My external plugins are
- Advances Tables
- Execute Code
- Kanban
- Mind Map
- Obsidian Git
- Outliner
- Ozan's Image in Editor Plugin
The main problem is, that every user has to figure out this by himself. Could you please add a hint in the installing documentation? Example path with included python.exe for windows users. Waiting before giving up. ;-)
I have a similar problem. Powershell does only show the copy-button. I miss the run-button (which appears with python scripts).
I use this configuration:
Shell path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Shell arguments: -file Shell file extension: .ps1
I deactivated all other extensions, reinstalled the extension, waited a few minutes but this does not help.
What can I do to solve the problem?
@merlinuwe I forgot to add powershell to the supported code blocks. It will (probably) work if you change powershell
to shell
or bash
Thank you very much. Yes, it works with shell
and bash
.
I also had to set the execution policy to unrestricted:
Thank you very much for your useful extension!
@merlinuwe That's interesting, I will add this to the readme.
I'm happy that you like it!
When changing from ITS Theme to Standard Obsidian Theme, there is no "copy" and "run"-Button anymore. Closing and restarting the application does not solve the problem.
I think this is an obsidian problem as the copy
button is not part of this plugin but implemented by obsidian core. The run
button is only added when obsidian loads the plugin and when obsidian calls all registered Markdown post processors or markdown code block processors as can be seen in main.ts
:
this.addRunButtons(document.body);
this.registerMarkdownPostProcessor((element, _context) => {
this.addRunButtons(element);
});
// live preview renderers
supportedLanguages.forEach(l=> {
console.log(`registering renderer for ${l}`)
this.registerMarkdownCodeBlockProcessor(`run-${l}`, async (src, el, _ctx) => {
await MarkdownRenderer.renderMarkdown('```' +l+ '\n' + src +'\n```' , el, '', null)
})
})
I will add this problem to the readme.
@merlinuwe I forgot to add powershell to the supported code blocks. It will (probably) work if you change
powershell
toshell
orbash
[/path/]
I am trying to Launch powershell code with no profile when i use this but when i add -noprofile to the end it fails to run any code. Am I missing something?