Macros Guide

ProtoML macros provide reusable rendering templates, mainly for HTML-oriented output.

What macros are good for

Macros are best when the same visual or structured output pattern appears repeatedly across documents. They help you standardize presentation without turning your documents into copy-pasted HTML fragments.

Using bundled macros

@macro badge "{{macro_dir}}/badge.pml"
@@macro=badge:text=review

Prefer quotes around paths in CLI usage.

protoparser --listMacros "{{macro_dir}}"
protoparser --macroHelp "{{macro_dir}}/finance/f_entry.pml"

Bundled macro areas

Writing custom macros

@new_macro
=name:statusPill
=template:
<span class="status-pill status-{{state}}">{{label}}</span>

When writing a macro, keep the input parameters obvious and stable. The best custom macros are easy to understand from the call site alone.

When to prefer imports, macros, or themes

External macro pack workflow

protoparser macro_install init
protoparser macro_install init_registry "./my-registry"
protoparser macro_install init_pack "legal-pack" "./my-registry"
protoparser macro_install add_registry "./my-registry"
protoparser macro_install install "legal-pack"

Use installed packs in a document

@macros_import ".protoml/macro-packs/macros.index.pml"

This is useful when multiple teams or projects should consume the same curated macro set instead of copying files around manually.

Practical advice

Related guides