UNIX Pipelines and I/O Streams

Abstract

This document demonstrates the advanced behavior of the MarkCharm compiler when operating as a native UNIX tool. Through POSIX stream separation, MarkCharm supports in-memory document injection via Standard Input (stdin) and direct extraction via Standard Output (stdout), enabling integration into complex pipelines.

1 The Pipe Paradigm

Unlike tools that force physical files to exist on disk, MarkCharm enables in-memory processing flows — the foundation of automation in CI/CD environments and Linux ecosystems.

There are three modes of operating streams in MarkCharm.

1.1 Pure Extraction (Stdout)

If you need generated HTML for a subsequent processing stream but want to keep reading the base file from disk, use the output flag -o -.

markcharm report.mc -o - | grep "<h1" > titles.html

In this mode, all informational messages (such as Compiling report.mc...) and diagnostics are routed to stderr, ensuring your pipeline receives exclusively the purified HTML tree.

1.2 Pure Injection (Stdin)

If your backend system or AI Agent generated a dynamic document and you don't want to pollute disk with temporary files, inject code into the compiler using a hyphen - in place of the input file.

echo "# Automated Report\nAll ok!" | markcharm - -o report.html

The - directive signals the Preprocessing Engine to capture memory at execution time.

1.3 Pass-Through Mode (Memory to Memory)

For maximum automation, MarkCharm can be piped between commands. If input is stdin and no output file is provided, the CLI intelligently assumes output goes to stdout.

cat report.mc | markcharm - | weasyprint - report.pdf

In this model, disk undergoes no write mutations. HTML flows through memory directly to Weasyprint.


2 Technical Caveats

Note

Base Directory Resolution (base_dir): When a file is read from memory (stdin), the compiler loses folder context. To ensure stability, MarkCharm assumes Current Working Directory (os.getcwd()) as anchor. Thus relative macros ({#USES ./plugins.mc}) or media (![photo](./img.jpg)) resolve from the working directory.

Warning

Secondary File Automation: If invoking AST dump (--ast-dump) along with Memory-to-Memory mode, the CLI avoids corrupting the HTML stream on stdout. The AST JSON falls back to safe mode, saving a file named stdin.audit.json in the execution directory.