https://github.com/linuxsuren/md-exec
Run commands or scripts which in Markdown files
https://github.com/linuxsuren/md-exec
markdown
Last synced: 11 months ago
JSON representation
Run commands or scripts which in Markdown files
- Host: GitHub
- URL: https://github.com/linuxsuren/md-exec
- Owner: LinuxSuRen
- License: mit
- Created: 2023-02-12T14:19:43.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T00:52:34.000Z (about 3 years ago)
- Last Synced: 2025-04-30T20:08:50.789Z (11 months ago)
- Topics: markdown
- Language: Go
- Homepage:
- Size: 57.6 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.codacy.com/gh/LinuxSuRen/md-exec/dashboard?utm_source=github.com&utm_medium=referral&utm_content=LinuxSuRen/md-exec&utm_campaign=Badge_Grade)
[](https://www.codacy.com/gh/LinuxSuRen/md-exec/dashboard?utm_source=github.com&utm_medium=referral&utm_content=LinuxSuRen/md-exec&utm_campaign=Badge_Coverage)

## Feature
* Support to run `shell`, `python`, `Golang`, and `Groovy`
* Load multiple Markdown files
## 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`
```shell
#!title: Print ip info
ifconfig
```
Run in different shells:
```zsh
#!title: Run in zsh
readlink /proc/$$/exe
```
```dash
#!title: Run in dash
readlink /proc/$$/exe
```
### Variable input support
In some use cases, we need to change the variables or command line flags. Try the following demo:
```shell
#!title: Variable Input Hello World
name=linuxsuren
echo hello $name
```
### Run in long time
```shell
#!title: Run long time
for i in 1 2 3 4 5
do
echo $i
sleep 1
done
```
### Run Python Script
```python3
#!title: Python Hello World
print('hello python world');
```
## Run Golang
```golang
#!title: Golang Hello World
fmt.Println("hello golang")
items := []int{1,2,3,4}
for _, item := range items {
fmt.Println(item)
}
```
## Run Groovy
```groovy
#!title: Groovy Hello World
class Foo {
void hello(){
println "hello"
}
}
new Foo().hello()
```
## Limitation
Please make sure the Markdown files meet Linux end-of-line.
You could turn it via: `dos2unix your.md`