ehsundar / obsidian-runner

Run code blocks inside any Markdown doc, including Obsidain docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Obsidian Runner

obsidian-runner CLI helps you format and run code blocks embedded inside any valid Markdown document and store results below the code block.

Supported Languages

  • Go

Showcase

obsidian-runner compiles and runs any go code. It also gofmts your code block in-place.

package main

import "fmt"

func main() {
	fmt.Println("results right below")
}
results right below

This small code block is also runnable but needs goimports tool installed to remove unused imports.

fmt.Println("results generated by obsidian-runner!")
results generated by obsidian-runner!

Usage

Standalone:

obsidian-runner -mdfile README.md

With Obsidian:

  1. Install obsidian-shellcommands plugin
  2. Install obsidian-runner:
    go install github.com/ehsundar/obsidian-runner@latest
  3. Add this command PATH='$PATH:/opt/homebrew/bin:/Users/ehsan/go/bin' /Users/ehsan/go/bin/obsidian-runner -mdfile {{file_path:absolute}}. you need to replace your username and maybe change path based on your OS.
  4. Use cmd+p to run obsidian commands. You may run your shell-command from there.

Warning

Do not use shell-command events to run obsidian-runner automatically. May cause inconsistency in the contents of the final result MD file.

About

Run code blocks inside any Markdown doc, including Obsidain docs


Languages

Language:Go 100.0%