Usage
md-exec
could exec the commands in the Markdown files.
For instance, it will execute those commands which in Markdown block via mde README.md
#!title: Print ip info
ifconfig
Run in different shells:
#!title: Run in zsh
readlink /proc/$$/exe
#!title: Run in dash
readlink /proc/$$/exe
In some use cases, we need to change the variables or command line flags. Try the following demo:
#!title: Variable Input Hello World
name=linuxsuren
echo hello $name
Run in long time
#!title: Run long time
for i in 1 2 3 4 5
do
echo $i
sleep 1
done
Run Python Script
#!title: Python Hello World
print('hello python world');
Run Golang
#!title: Golang Hello World
fmt.Println("hello golang")
items := []int{1,2,3,4}
for _, item := range items {
fmt.Println(item)
}
Limitation
Please make sure the Markdown files meet Linux end-of-line.
You could turn it via: dos2unix your.md