PHPackages                             bashup/mdsh - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. bashup/mdsh

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

bashup/mdsh
===========

Multi-lingual, Markdown-based Literate Shell Programming

2031015Shell

Since Jul 1Pushed 4y ago5 watchersCompare

[ Source](https://github.com/bashup/mdsh)[ Packagist](https://packagist.org/packages/bashup/mdsh)[ RSS](/packages/bashup-mdsh/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Multi-Lingual Literate Programming with `mdsh`
----------------------------------------------

[](#multi-lingual-literate-programming-with-mdsh)

`mdsh` is a bash script compiler and interpreter for markdown files. It can be used in a `#!` line to make markdown files executable, or it can be used as a standalone tool to generate dependency-free, distributable bash scripts from markdown files.

By default, `mdsh` only considers `shell` code blocks to be bash code, but you can also use `@mdsh` blocks to define handlers for other languages. For example, this script will run `python`-tagged code blocks by piping them to the `python` command:

```
#!/usr/bin/env mdsh

# Hello World in Python

The following code block is executed at compile time (due to the `@mdsh`).
(The first word on the opening line could be `shell` or `sh` or anything
else, as long as the second word is `@mdsh`.)

```bash @mdsh
mdsh-lang-python() { python; }
```

Now that we've defined a language handler for `python`, this next code
block is translated to shell code that runs python with the block's
contents on stdin:

```python
print("hello world!")
```
```

Running the above markdown file produces the same results as this equivalent bash script:

```
#!/usr/bin/env bash
{ python; }
