Introducing the Marked Conductor
I’ve completed my latest side project, the Marked Conductor. Here’s the backstory:
Marked 2 offers the option to use Custom Processors (and Preprocessors) which allow you use Markdown (and other) flavors with your own commands to convert them to HTML. This is commonly used for processing with Pandoc. Personally, I use it to process my blog posts (and Bunch and other Jekyll help docs) with Kramdown and a bunch of special handlers for previewing the custom Liquid tags and plugins I’ve built, process TaskPaper files with their own functions, and process everything else with Marked’s built-in processors. In those scripts, you can use environment variables like $MARKED_EXT
(the file’s extension) or $MARKED_ORIGIN
(the file’s path) to fork the script and process differently based on things like file type or location. But my custom processor script was getting unwieldy with all of the conditions I was creating, and for people with limited scripting knowledge, it meant having to turn custom processors on and off based on the needs for the current document.
Enter Conductor. It’s a command line utility that can be set as the custom processor in Marked. It reads from a YAML configuration file where conditions are written in natural language (e.g. tree contains .obsidian) and trigger either a script or a command. Conditions can be booleans (extension is md AND tree contains .obsidian) or they can be nested infinitely to create forked “tracks” for handling any type of document. It offers ways of matching YAML frontmatter keys, matching content with strings or regular expressions, detecting whether a file or directory exists anywhere in the parent folders of the file, and more.
I won’t go into all of the features in this post, but they’re all detailed on the project page. The entire project is available on GitHub, but it’s published as a gem, so installation is as easy as running gem install marked-conductor
. Running conductor
once from the command line will build out all of the configuration directories and files. Then it’s just a matter of setting up your own tracks and actions.
I think this project will be of great interest to anyone using Custom Processors in Marked. Whether you’re an avid scripter who’s extended it in interesting ways, or just someone who might want Pandoc for documents in your “Work” folder, but Kramdown for documents in your “Blogging” folder, this project makes it very easy to run Custom Processors conditionally.
By the way, I’m waiting on my Obsidian plugin for Marked to be accepted into the Community Plugins. Once that happens, I have a post all about using Marked with Obsidian that I think Obsidian users will love. Stay tuned.