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

Install problems only at first use.

Open merlinuwe opened this issue 2 years ago • 7 comments

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. ;-)

merlinuwe avatar May 27 '22 18:05 merlinuwe

I have a similar problem. Powershell does only show the copy-button. I miss the run-button (which appears with python scripts).

image

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 avatar Jul 07 '22 07:07 merlinuwe

@merlinuwe I forgot to add powershell to the supported code blocks. It will (probably) work if you change powershell to shell or bash

twibiral avatar Jul 07 '22 07:07 twibiral

Thank you very much. Yes, it works with shell and bash.

I also had to set the execution policy to unrestricted:

image

Thank you very much for your useful extension!

merlinuwe avatar Jul 07 '22 08:07 merlinuwe

@merlinuwe That's interesting, I will add this to the readme.

I'm happy that you like it!

twibiral avatar Jul 07 '22 10:07 twibiral

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.

twibiral avatar Jul 07 '22 11:07 twibiral

@merlinuwe I forgot to add powershell to the supported code blocks. It will (probably) work if you change powershell to shell or bash [/path/]

tan1603 avatar Jul 08 '22 00:07 tan1603

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?

Cy-Gor avatar Aug 05 '22 17:08 Cy-Gor