March Docs

BlobParser

lib/scroll/blob_parser.march — Strip __SCROLL_BLOB__ sentinels from raw cell stdout and return them as structured blob items.

Stage 2.1 of specs/parity-plan.md introduces binary output via a sentinel protocol. User (or stdlib) code emits:

__SCROLL_BLOB__:<mime>:<base64>\n
__SCROLL_BLOB_END__\n

anywhere in stdout. runtime.march passes the raw output through BlobParser.parse/1 before forwarding to the browser. The browser renders each blob via renderBlob (see assets/js/scroll.js Stage 2 additions).

Design:

  • parse/1 is the single public entry point.
  • All helpers are pfn — accessible to tests, not exported as public API.
  • Size cap: 8 MB of raw binary data = ~11.2 MB of base64. Any larger
  blob is dropped and replaced with a human-readable error line in the
  text output.
- Malformed sentinels (missing end marker, empty MIME, no colon) are
  silently passed through as plain text — we never lose user output.

Functions

fnmax_blob_b64_bytesmax_blob_b64_bytes() : Int do 11184812 end#

Maximum base64 character count permitted for a single blob (≈ 8 MB decoded).

fnparseparse(raw : String) : (String, List((String, String)))#

Parse raw cell stdout, extracting __SCROLL_BLOB__ sentinel blocks.

Returns (clean_text, blobs) where:

  • clean_text is the stdout with all sentinel blocks removed (and error
  placeholders inserted for any blobs that exceeded the size cap).
- `blobs` is a list of `(mime, base64_data)` pairs in emission order.

Malformed sentinels (missing end marker, empty MIME, no colon between MIME and data) are treated as plain text and kept in clean_text unchanged.

Examples

march> BlobParser.parse("hello\n")
("hello\n", [])
march> BlobParser.parse("")
("", [])
fnparse_headerparse_header(header : String) : Option((String, String))#
fnparse_with_limitparse_with_limit(raw : String, limit : Int) : (String, List((String, String)))#

Like parse/1 but with a custom base64 size cap. Intended for testing.