twibiral / obsidian-execute-code

Obsidian Plugin to execute code in a note.
MIT License
994 stars 61 forks source link

[BUG] Code blocks not working #362

Closed Kamek437 closed 1 month ago

Kamek437 commented 1 month ago

I just installed obsidian and this plugin on windows 11 and I canno't get the code to run, no run button like in the pics, and there is no output when I hit run all code blocks. Is there some special way to get this to function? I'm just inserting new code blocks but also tried the three backticks way. I have node installed and pythong both functioning well and available from command line.

Windows 11, latest patches. Obsidian latest version. Python 3.10, Node v20.14.0.

Steps to reproduce the behavior: Install everything like normal and try to run a simple hello world block.

Code block should run and output something OR give an error message with more info.

Screenshot 2024-06-11 133452 Am I doing something wrong? In theory it should just work but I'm new to Obsidian and don't know where to find the logs. It should give some sort of error if it doesn't work though.

twibiral commented 1 month ago

You need to add the language name to the code block, like this:

```python
print("Hello World")
Kamek437 commented 1 month ago

I feel stupid now. Thank you.

Kamek437 commented 1 month ago

In the top bar isn't there supposed to be a button to run the code? It doesn't show up for me.

Kamek437 commented 1 month ago

I tried you're marking the code type but no change. Where can I see the output of the extensions? Or a log file or something I can check? It isn't loading correctly I think because the button didn't show up in the top bar. The runtime thingy loads but never shoes a runtime so I guess it's loading.

twibiral commented 1 month ago

The run button will only appear when you view it in rendered mode (you can switch to the rendered mode using this button in the lower right corner: image)

What exactly do you mean with top bar? The run button is only supposed to be directly at each code block.

Kamek437 commented 1 month ago

Thank you, I feel stupid.

twibiral commented 1 month ago

Don't worry ^^