Conductor fixes and improvements
I’ve made some important fixes and handy improvements to the Marked Conductor since it was first published.
I’ve made my own config available as an example. Not all of the scripts are polished, but it’s complete enough to show how I’m using it. I still need to finish breaking my Jekyll preprocessor script into more manageable chunks, which is complicated because every little method has conditionals, but that’s coming. In the meantime, you can find my work in progress here.
Here’s the rundown.
Titles and STDERR Output
Conductor now outputs more helpful information to STDERR, which you can view in Marked using Help->Show Custom Processor Log. It will display a list of conditions met for the current document, along with any errors. You can also now add a title
key to any track, and it will be used in the STDERR output instead of the full condition, which is handy for long conditions with lots of booleans. So instead of:
Condition met: tree contains .obsidian AND (extension is md OR extension is markdown)
You can just get:
Condition met: Obsidian Document
Multiple scripts
Conductor can now run multiple scripts in sequence. There are two ways to do this.
- Instead of a
script
orcommand
, you can usesequence
. Then in an array list, you can define a series of- script: xxx
and- command: xxx
type lines and they’ll be run in order, with the output of one being passed to the next, getting the final output from the last script/command in the list. - You can add
continue: true
to any track or block. Normally, Conductor stops processing when a condition is met. Withcontinue: true
, it will continue matching conditions after processing the one with the key, again passing the output of each one to the next. This allows you to, for example, run a preprocessor on a narrow selection of documents, and then run those through a more generalized processor that catches more documents than the narrow selection does.
Changelog
Here’s the full changelog since release.
NEW
- Test for pandoc metadata (%%) with
is pandoc
oris not pandoc
- Add
sequence:
key to allow running a series of scripts/commands, each piping to the next - Add
continue: true
for tracks to allow processing to continue after a script/command is successful filename
key for comparing to just filename (instead of full path)- Add
is a
tests forarray
,number
,integer
, andfloat
- Tracks in YAML config can have a title key that will be shown in STDERR ‘Conditions met:’ output
- Add
does not contain
handling for string and metadata comparisons - Added test for MMD metadata, either for presence of meta or for specific keys or key values
- Allow
has yaml
orhas meta
(MultiMarkdown) as conditions
IMPROVED
- Return NOCUSTOM if changes are not made by scripts/commands, even though condition was matched
- Use YAML.load instead of .safe_load to allow more flexibility
- Trap errors reading YAML and fail gracefully
FIXED
- Use STDIN instead of reading file for conditionals
- String tests read STDIN input, not reading the file itself, allowing for piping between multiple scripts
- Always wait for STDIN or Marked will crash. Still possible to use $file in script/command values
- More string encoding fixes
- “path contains” was returning $PATH instead of the file path
- First-run config creating directory instead of file
- Frozen string/encoding issue on string comparisons
- Encoding errors on string methods
Check out the Conductor project for more details!