---
title: Conductor filters simplify basic operations
date: 2024-05-24 13:37
slug: conductor-filters-simplify-basic-operations
categories:
- Code
tags:
- scripting
- marked
- conductor
- markdown
---

[introducing]: https://brettterpstra.com/2024/04/25/introducing-the-marked-conductor/ "Introducing the Marked Conductor"
[conductor]: https://brettterpstra.com/projects/conductor
[Marked]: https://marked2app.com
[config]: https://github.com/ttscoff/conductor-config/tree/main

![conductor.png](https://brettterpstra.com/uploads/2024/04/conductor.png)

[Last month][introducing] I released [Conductor], a tool for handling multiple Custom Processors in [Marked]. It allows you to use natural language conditions to determine which command or script to run, either as preprocessor or processor for Marked. But I found a lot of [my scripts][config] were just injecting metadata or performing other simple actions, so I added a new feature to Conductor called Filters. Filters are just shortcuts to avoid having to write simple (often 3 or 4 line) scripts.

Like `command:` or `script:` actions, you can now just use `filter: filterName(parameters)` to do things like setting a Marked Style, injecting or stripping metadata (YAML/MMD aware), or doing search and replaces on the content. These can be run in a `sequence:` to combine multiple filters.

### Available Filters

The available filters are:

- `addMeta(key, value)`/`setMeta(key, value)` -- adds or updates a meta key, aware of YAML and MMD
- `stripMeta` -- strips all metadata (YAML or MMD) from the content
- `stripMeta(key)` -- removes a specific key (YAML or MMD) 
- `setStyle(name)` -- sets the Marked preview style to a preconfigured Style name
- `replace(search, replace)`/`replaceAll(search, replace)` -- performs a search and replace (global with `replaceAll`). 
	- If *search* is surrounded with forward slashes followed by optional flags (*i* for case-insensitive, *m* to make dot match newlines), e.g. `/contribut(ing)?/i`, it will be interpreted as a regular expression. The *replace* value can include numeric capture groups, e.g. `Follow$2`.

Update to the latest version using `gem install marked-conductor` (may vary depending on how you installed it originally) to get the new features, see the [project page][conductor] for details, and check out my [config] to see examples.

If there are any simple procedures you're currently using scripts to handle that aren't covered by these, please let me know in the comments what filters you'd like to see added!

### Also, easier testing

There's now a file in the repo called [`test.sh`](https://github.com/ttscoff/marked-conductor/blob/main/test.sh) that makes it way easier to test configurations from the command line. Just run `test.sh FILENAME` to process a file as if it were being opened in Marked. You can use `-o err` to output only the STDERR response, which will show which conditions are being matched, and you can use `-p` to define the phase as either `pre` or `pro` to run as Preprocessor or Processor, respectively.

---

Brett is a writer and developer living in Minnesota, USA. You can follow him as ttscoff. This content is supported by readers like you. [More about Brett](https://brettterpstra.com/contact.md), including social links.

Copyright © 2026 Brett Terpstra. All rights reserved.
