Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@show / Python - invalid syntax (<code block>) #404

Open
luckman212 opened this issue Feb 25, 2025 · 5 comments
Open

@show / Python - invalid syntax (<code block>) #404

luckman212 opened this issue Feb 25, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@luckman212
Copy link

luckman212 commented Feb 25, 2025

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)
Image
@twibiral twibiral added the bug Something isn't working label Mar 1, 2025
@twibiral
Copy link
Owner

twibiral commented Mar 1, 2025

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

@luckman212
Copy link
Author

luckman212 commented Mar 1, 2025

Thanks for looking 🙏 - I will test 2.1.2 as soon as I get home.

@luckman212
Copy link
Author

matplotlib test was a success...

Image

but cat img test is still saying invalid syntax (<code block>, line 7)

Image

@twibiral
Copy link
Owner

twibiral commented Mar 2, 2025

@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...

@luckman212
Copy link
Author

luckman212 commented Mar 2, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants