markdown_player
▶️ Executable markdown files.
Write markdown documentation, run markdown documentation!
demo
- Write code in codeblocks
- Run
markdown_player /path/to/file.md --appendOutput
- Observe the output
const fileType = "markdown";
const description = `Runs code fences in a ${fileType} file.`;
console.log(description);
Runs code fences in a markdown file.
The above output was auto-added to this document by the --appendOutput
flag!
features
- share execution environments between codeblocks
- configure codeblocks to be run with custom commands
- write codeblocks to disk, permanently or with auto-removal
examples
The following are written in a narrative style to demonstrate functionality.
Share execution environments
Sharing variables can be achieved by adding a {group: name}
to the codeblock
meta.
Math is important. Learn math! Consider this function:
const square = (x: number) => x * x;
What if we passed a two?
const twoSquared = square(2);
console.log(twoSquared);
4
What about the square of a square?
console.log(square(twoSquared));
16
Wow! Sharing variables is great!
why?
Documentation or demonstration? Which is more powerful for helping users? Why settle for just one? What if you could deliver both, from the exact same markdown content?
Turn your markdown into an application!
deno install -A --unstable ...
api
playFile(...)
configuration
codefences
Codef ences can be configure via compact yaml in the codefence meta section.
markdown codefences have the form:
<TRIPLE_BACKTICK><LANG><META><BODY><TRIPLEBACKTICK>
Example:
delete me
console.log(123);
123
```ts {filename: cool file.ts, cmd: deno, args: [eval, $ARG]}
console.log(123);
```
You can verify your compact YAML syntax using https://yaml-online-parser.appspot.com/.
FAQ
Error: Exec format error (os error 8)
Did you try to execute a file that was not a binary, or had no
#!/usr/env/bin LANG
block?