Show HN: Mdx – Execute your Markdown code blocks, now in Go (github.com)
Hey HN! I recently came across makedown here on HN and loved the concept. Wanting to learn Go, I thought this could be a great starter project - so I started working on my own Go implementation, which I’m calling mdx (https://github.com/dim0x69/mdx).
Key Features:
- Define dependencies between commands
- Supports shebangs
- Ability to pass arguments to code blocks
Would love feedback and thoughts!
Ref. makedown: https://github.com/tzador/makedown. Thanks for the idea! :)
57 comments
[ 4.6 ms ] story [ 113 ms ] thread- Astro: https://docs.astro.build/en/guides/integrations-guide/mdx/
- Docusaurus: https://docusaurus.io/docs/markdown-features/react
- Eleventy: https://www.11ty.dev/docs/languages/mdx/
- NextJS: https://nextjs.org/docs/pages/building-your-application/conf...
https://mdxjs.com/
I wrote my own version too, a while back, because it seemed like it would be useful (and indeed it has been) - a golang tool to list/search/run named blocks from markdown, joining multiple blocks together if instructed to do so:
https://github.com/skx/runme
We've expanded significantly onto the idea of a toy script/utility to bring multi-modality (editor, notebook, terminal, browser) with shared sessions to what's at the core, a universal task runner (see architecture link below).
I'd love to chat about combining efforts if you love hacking on this. The same goes for the author of `mdx`.
https://docs.runme.dev/resources/architecture
One hint: your examples need to be escaped to show the fence syntax. Add 4 spaces I think.
I can't see the fence instructions (without entering raw, I guess)
We could expect failure conditions or assert correct outcomes.
It could become a little library of examples that change over time, as the software changes, granting us peace of mind that everything still works.
In some of my projects I have little snippets of cli commands in the main README.
When I open the project in JetBrains IDE and I open the README of my project there, I can click on each code block to run it.
This way I can for example start up dependencies like say a little python3 web server to serve static files from one of the subdirs, simply by clicking on it in the readme. Instead of copy-pasting from the readme, and even instead of Ctrl+R in a terminal window and finding the correct commands for a project from history.
It almost reminds me a little bit of Plan9 and their Acme editor, where they were blurring the lines between text and commands. In Acme you can type a piece of text and then middle-button click I think it was to run the text as a command. Having executable blocks of code interspersed in a markdown document feels a little bit like that although in a different, more limited manner.
It was like a super rudimentary Jupyter Notebook system of my own making.
Eventually I switched away from my own run-and-insert system.
It's all open source. Please get involved! We'd be happy to have you.
[0]: https://github.com/twibiral/obsidian-execute-code
https://github.com/coezbek/baker
I call this a Project-Setup-as-Code tool.
Supports backticks for shell and triple backticks for executing Ruby code.
If blocks are successfully executed they are marked as done (using markdown [x] checkboxes). So you can incrementally run a file without executing stuff twice.
The central use case is to have a fun and fast way to play with browser code, using your favorite editor, and literate programming techniques. All while being open source, local first, and minimalist.
The repo (https://github.com/javajosh/simpatico/) is not yet npm/npx compatible so you have to fork and run. This is a local first, minimalist project that has ~2 small dependencies, which themselves have no deps, so publishing was not a priority.
Eventually I'd like to automate an md-> js process, such that the md is the canonical source for javascript and the final js is a build product. I'd also like to clean up the code and publish to npm, but sadly someone is squatting on the @simpatico handle and npm won't do anything. :(
Org mode is stellar at that "code in document" tangling, but I'll be honest that I loathe the M-| behavior in emacs since, unlike its vim friend, it puts the output in a separate buffer, placing the burden upon me to copy/cut it back into the source buffer
Well, this will mean Org files exported to Markdown can remain executable just like they were in Emacs, so maybe this makes Org Babel more valuable as well, for those of us that prefer a structured markup language for notes and literate programming
And thanks to pandoc it's not hard to go back and forth
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-...
With apologies to Henry Spencer.
We did similar at a company I worked for 15 yrs ago
I don't think it ever had huge adoption across whole teams, but I hope if there are new implementations that they take away a number of lessons you can gather from 15 years of org-babel.
```sh name="build" deps=["install"]
npm run build
```
This would be displayed just fine in github, as it is valid gfm.
1: https://github.com/stateful/runme#runme-runs-markdown-- (Apache 2, golang)
I wondered why Runme wasn't already mentioned but it seems the comment got nested under a dead thread https://news.ycombinator.com/item?id=41955834
If you like this, another similar tool, though one specifically geared towards builds, is xc.
https://xcfile.dev/
https://github.com/josephbergevin/codebook-md
Have a look, I'd love to get some feedback. For me, it's in a good enough state that I'm able to use it in my everyday coding - but it definitely has a lot of room for improvement.