Run multiple Preview Filters simultaneously

82 views
Skip to first unread message

Christopher Finazzo

unread,
Apr 2, 2025, 9:34:13 PM4/2/25
to BBEdit Talk
I have a script that strips out front matter from a file when it is shown in the HTML Preview. I also want to visually inspect my links to make sure that they display correctly, so I also pass files through Markdown.pl inside the preview window.

Is there a way to run 2 scripts in parallel inside the preview to accomplish this?

On paper, this should work by combining the two, but I'm rather lost as to how to make it happen.

jj

unread,
Apr 4, 2025, 12:29:16 PM4/4/25
to BBEdit Talk

Hi Christopher,

As both your scripts read from stdin and write to stdout,
you could probably pipe them in a third script like so:

    #!/usr/bin/env zsh
   
    /path/to/perl Strip_YAML.pl | /path/to/perl Markdown.pl

and use it as a text filter.

Note that BBEdit is already equipped to preview Markdown files.
See the documentation in BBEdit Help > User Manual and search for 'Markdown'.

HTH,

Jean Jourdain

GP

unread,
Apr 6, 2025, 5:04:49 AM4/6/25
to BBEdit Talk
Jean Jourdain's solution will work with some fine point additions. 

1. The Strip_YAML.pl and Markdown.pl files have to have their file execute permission set so the piping script can invoke those scripts for execution. Where you have those two scripts isn't critical but for convenience of using them as stand alone BBEdit text filters you can place them in BBEdit's Text Filters folder ~/Library/Application Support/BBEdit/Text Filters/. (Or you can place them in BBEdit's Preview Filters folder if you want the option of using them as separate stand alone Preview filters as well as the combined piped script filter.) 

2. The piping script has to be placed in BBEdit's Preview Filters folder, ~/Library/Application Support/BBEdit/Preview Filters/, so the script's file name will be included in the Preview window's "Filter:" pop down menu. Once that script's file name has been selected from the Filter: popup menu subsequent invocations of Markup -> Preview in BBEdit will automatically run that script with the contents of the frontmost window when Markup -> Preview in BBEdit is chosen. You don't necessarily have to have that script's file execute permission set.

3. If you use the file name with a space in it as your script github link shows (i.e., "Strip YAML.pl"), you'll need to use quoting or space escaping so the shell will interpret the file path as a single contiguous string instead of multiple space separated strings.
Reply all
Reply to author
Forward
0 new messages