{"id":19658136,"url":"https://github.com/cdaringe/markdown_player","last_synced_at":"2025-06-11T16:07:43.811Z","repository":{"id":42576049,"uuid":"354615664","full_name":"cdaringe/markdown_player","owner":"cdaringe","description":"Executable markdown files. Documentation \u0026 demonstrations, all in one!","archived":false,"fork":false,"pushed_at":"2023-10-24T23:28:08.000Z","size":63,"stargazers_count":4,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-08T01:53:47.511Z","etag":null,"topics":["demo","deno","documentation","markdown"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cdaringe.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-04T18:17:51.000Z","updated_at":"2024-05-31T05:14:01.000Z","dependencies_parsed_at":"2022-09-11T07:12:30.848Z","dependency_job_id":"fbee64ff-ffc1-4c1b-abe7-4a77d54b6aa6","html_url":"https://github.com/cdaringe/markdown_player","commit_stats":{"total_commits":27,"total_committers":5,"mean_commits":5.4,"dds":0.4444444444444444,"last_synced_commit":"0b132c5e815ae59030b74800a0620b8eb4b4ddbc"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/cdaringe/markdown_player","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdaringe%2Fmarkdown_player","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdaringe%2Fmarkdown_player/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdaringe%2Fmarkdown_player/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdaringe%2Fmarkdown_player/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdaringe","download_url":"https://codeload.github.com/cdaringe/markdown_player/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdaringe%2Fmarkdown_player/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259293362,"owners_count":22835599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["demo","deno","documentation","markdown"],"created_at":"2024-11-11T15:36:13.474Z","updated_at":"2025-06-11T16:07:43.756Z","avatar_url":"https://github.com/cdaringe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# markdown_player\n\n▶️ Executable markdown files.\n\nWrite markdown documentation, _run_ markdown documentation!\n\n## Install\n\nInstall the CLI:\n\n`deno install --unstable -f -A -n markdown_player \"https://deno.land/x/markdown_player@v1.2.3/src/bin.ts\"`\n\nInstall the `deno` library:\n\n```ts {skipRun: true}\nimport * as markdownPlayer from \"https://deno.land/x/markdown_player@v1.2.3/src/mod.ts\";\nmarkdownPlayer.playFile(\"readme.md\");\n```\n\n## How it works\n\n- Reads a markdown file\n- Parses all\n  [fenced code blocks](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks)\n- Executes each code fence in an independent or shared process\n- Captures and re-emits command output!\n\n## Preview\n\nThis is a living document. Let's observe markdown_player in action!\n\n- Write code in code blocks\n- Run `markdown_player /path/to/file.md --appendOutput`\n- Observe the output\n\n```ts\nimport { getEmojiByName } from \"https://deno.land/x/getmoji@1.2.3/mod.ts\";\nconst fileType = \"markdown\";\nconst description = `Runs code fences in a ${fileType} file`;\nconsole.log(`${description} ${await getEmojiByName(\"pizza\")}`);\n```\n\n```txt {skipRun: true, isExecutionOutput: true}\nRuns code fences in a markdown file 🍕\n```\n\nThe above output was auto written to this document by using the `--appendOutput`\nflag!\n\n## Features\n\n- share execution environments between code blocks\n- configure code blocks to be run with custom commands\n- optionally write code blocks to files, with support for optional auto-removal\n\n## API\n\nCode fences can be configured via single line yaml in the meta section. Consider\nthe following markdown meta:\n\n`` ```bash {file: {name: greeting.sh}} ``\n\nNow, apply it to a real code block (warning, the meta is hidden by real\ncodeblocks, unless you look at the markdown source):\n\n```bash {file: {name: greeting.sh}}\n# creates a file called \"greeting.sh\", as specified in the meta\necho \"hello $USER!\"\n```\n\n```txt {skipRun: true, isExecutionOutput: true}\nhello cdaringe!\n```\n\n...and that file gets run!\n\n| meta-option         | type       | description                                                                                                  |\n| ------------------- | ---------- | ------------------------------------------------------------------------------------------------------------ |\n| `skipRun`           | boolean?   | Do not execute this code block                                                                               |\n| `group`             | string?    | Run any same named group code blocks in the same file                                                        |\n| `cmd`               | string?    | Executable to run                                                                                            |\n| `args`              | string\\[]? | Args to pass to the executable. Use the string \"$ARG\" to get the contents of the code fence                  |\n| `file`              | object?    | Flush the code block to a file then execute it. This is the default operation mode.                          |\n| `file.name`         | string?    | Name the file. Otherwise, a random filename is generated                                                     |\n| `file.autoRemove`   | boolean?   | Set to false to keep the file. Otherwise, it is deleted by default                                           |\n| `isExecutionOutput` | boolean?   | Signify that this block is for capturing stdio from the above code block. Generally considered a private API |\n| `skipOutput`        | boolean?   | Run the block, but skip writing output if appendOutput mode is also requested                                |\n\nYou can verify your compact YAML syntax using\nhttps://yaml-online-parser.appspot.com/.\n\n## Examples\n\n### Meta blocks\n\nThe following block has meta: `` ```js {cmd: node, args: [\"--eval\", $ARG]} ``\n\n```js {cmd: node, args: [\"--eval\", $ARG]}\n// no file is written\nconsole.log(123);\n```\n\n```txt {skipRun: true, isExecutionOutput: true}\n123\n```\n\nThe following block has meta:\n`` ```js {file: {name: 456-demo.js, autoRemove: true}, cmd: node, args: [456-demo.js]} ``\n\n```js {file: {name: 456-demo.js, autoRemove: true}, cmd: node, args: [456-demo.js]}\nconsole.log(456);\n```\n\n```txt {skipRun: true, isExecutionOutput: true}\n456\n```\n\n### Share execution context\n\nSharing variables can be achieved by adding a `{group: name}` to the codeblock\nmeta. All items in a `group` eventually get run from a single file, where all\nblocks are combined into a single file.\n\nMath is important. Learn math! Consider this function:\n\n```ts {group: group_demo}\nconst square = (x: number) =\u003e x * x;\n```\n\nWhat if we passed a two?\n\n```ts {group: group_demo}\nconst twoSquared = square(2);\nconsole.log(twoSquared);\n```\n\n```txt {skipRun: true, isExecutionOutput: true}\n4\n```\n\nWhat about the square of a square?\n\n```ts {group: group_demo}\nconsole.log(square(twoSquared));\n```\n\n```txt {skipRun: true, isExecutionOutput: true}\n16\n```\n\n### Run a code block, but skip output\n\nuse the `skipOutput` meta flag: `` ```ts {skipOutput: true} ``\n\n```ts {skipOutput: true}\n// print out an enormous string!\nconsole.log([...Array(1e4)].join(\"a\\n\"));\n```\n\n## FAQ\n\n\u003e Error: Exec format error (os error 8)\n\nDid you try to execute a file that was not a binary, or had no\n`#!/usr/env/bin LANG` block?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdaringe%2Fmarkdown_player","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdaringe%2Fmarkdown_player","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdaringe%2Fmarkdown_player/lists"}