@show / Python - invalid syntax (<code block>)
macOS 15.3.1 + Obsidian 1.8.9
I am trying a simple @show example, not sure if this is a regression since 2.1.0 since I am pretty sure it worked before!
import os
catimg = '/'.join([@vault_path,'attach',@title,'cat.png'])
print(f'path:{catimg}\nexists:{os.path.exists(catimg)}')
result:
path:/Users/luke/Sync/Obsidian/Main/attach/Obsidian Execute Code plugin/cat.png
exists:True
import os
catimg = '/'.join([@vault_path,'attach',@title,'cat.png'])
print(f'path:{catimg}\nexists:{os.path.exists(catimg)}')
@show(catimg, 25%, 25%, left)
result:
invalid syntax (<code block>, line 10)
Hi, I think the problem was the extra "/" that was introduced by concatenating the app line ("app://..../") and the image link ("/some/path/..."). I don't have a mac and can't test this. Can you please update the plugin (v 2.1.2) and tell me if it worked?
Also: Can you try creating a plot to see if it shows up correctly? e.g., like this:
import matplotlib.pyplot as plt
import numpy
x = numpy.array(list(range(10)))
y = numpy.sin( x )
plt.plot( x , y )
plt.show()
This is related to #405
Thanks for looking 🙏 - I will test 2.1.2 as soon as I get home.
matplotlib test was a success...
but cat img test is still saying invalid syntax (<code block>, line 7)
@luckman212 Okay, I have no clue why it doesn't work.... can you go to the developer view (ctrl+i for windows) and select the code block output. There should be some html code that isn't rendered correctly. Maybe this can help me understand the problem better.
It's working perfectly on my machine, so unfortunately I cannot check it myself...
I tried a small variation as well, it still gives me invalid syntax (<code block>, line 7) error:
import os
a = "{}/attach/{}".format(@vault_path,@title)
catimg = os.path.join(a,'cat.png')
@show(catimg, 25%, 25%, left)
I don't see any code (invalid or otherwise) in the Dev Tools console... is there a setting I need to enable to show the generated code that the plugin is trying to execute?