Jun 29 2025
corre - Execute shell scripts embedded within text
corre [OPTIONS]...
Executes shell scripts nested within text as marked by some delimiter, and then replaces the shell script with its STDOUT.
By default, the input corre reads from is the STDIN and the output is
printed to the STDOUT. These can be redirected via file redirection or
the -i and -o flags.
The default delimiter used to mark an embedded script is the opening
tag “!((” and the closing tag “))!”. The delimiter can be changed with
the -d flag.
The embedded scripts are called from the directory that corre is called from.
Corre exports only a single function:
corre::run_embedded_scripts(
text: String, // The input text
opening_tag: &str, // The opening tag that marks a script start
closing_tag: &str, // The closing tag that marks a script end
recur: bool, // Whether or not to recur on script outputs
) -> Result<String, PopenError>Simply pass the input text and the delimiters, and corre will return the processed output text.
Requires the rust toolchain and the cargo CLI.
cargo install corre
Corre can be used to include partial files in other files as such:
<!-- ./par/main.md -->
# A main file
Some text from the main file, followed by
some text from a partial file:
!((cat ./par/partial.md))!
And then some more text after the partial!<!-- ./par/partial.md -->
Some text in a partial file.corre -i ./par/main.md -o ./par/processsed_main.md
<!-- ./par/processsed_main.md -->
# A main file
Some text from the main file, followed by
some text from a partial file:
Some text in a partial file.
And then some more text after the partial!It may be useful to pass the -r flag to operate
recursively on script outputs if you plan to have multiple layers of
inclusion. Otherwise, you would have to call corre yourself before
calling cat.
<p>
There are !((ls ./src/ | wc -l))! files in the
<code>./src/</code> directory:
</p>
<ul>
!((
for FILE in $(ls ./src/); do
echo "<li><a href='./src/$FILE'><code>$FILE</code></a></li>"
done
))!
</ul>
<p>
There are 2 files in the
<code>./src/</code> directory:
</p>
<ul>
<li><a href='./src/lib.rs'><code>lib.rs</code></a></li>
<li><a href='./src/main.rs'><code>main.rs</code></a></li>
</ul>