obsidian-execute-code icon indicating copy to clipboard operation
obsidian-execute-code copied to clipboard

Extra slashes `//` in magic command output? and `None` if Python code does not print anything to stdout...

Open luckman212 opened this issue 1 year ago • 5 comments

macOS 15.3.1 + Obsidian 1.8.7

// slashes

Not sure if it changed since 2.1.0 but... @vault_url is generating double slashes in its output

print("Vault url:", @vault_url)
Image

None output

Also, if there is nothing printed to stdout, the codeblock displays the text None. Pretty sure that isn't intentional either.

print("Vault url:", @vault_url)

vs

print('hello')
print("Vault url:", @vault_url)
Image

luckman212 avatar Feb 25 '25 14:02 luckman212

Just reporting, with 2.1.2 ... still the same.

Example, I would expect the below to only show the image, but None is printed as well

Image

luckman212 avatar Mar 01 '25 22:03 luckman212

Thanks for checking @luckman212 ! Are you executing the code in notebook mode? (That would explain the None)

If you try print("Vault url:", @vault_url) again, does it still print the wrong path? Hopefully I was at least able to fix that part...

twibiral avatar Mar 02 '25 14:03 twibiral

Yes @twibiral the double slash problem is fixed 🚀

Not sure what you mean "notebook mode" - reading mode? If that's what you meant then "Yes" I am executing the codeblocks in Reading Mode. I still use the split-pane view (left side "source" mode and right side "reading" mode, I am most comfortable with this setup (I don't use Live Preview mode).

luckman212 avatar Mar 02 '25 15:03 luckman212

Oh I see Notebook Mode is in the Plugin settings... sorry. I didn't realize, not sure what that setting does yet, I will try to learn about it.

Anyway "yes" the Notebook Mode toggle was "On", I also tried turning it Off which did not make a difference.

luckman212 avatar Mar 02 '25 15:03 luckman212

@luckman212 The notebook mode creates a global environment for the code you run, similar to Jupyter notebook. It works fine most times, but sometimes it has some funky issues

twibiral avatar Mar 02 '25 15:03 twibiral