September 11, 2026
Abstract
This document demonstrates the power of the {$DATA} directive. With it, structured data files (.json, .yaml, .toml) are read during preprocessing and dynamically injected into the compiler as macros (native commands). This ensures reports and technical opinions share a single "source of truth", mitigating typos and facilitating automation via data pipelines.
Technical Explanation: The {$DATA} pragmas in the preamble intercept data files during Phase 1 (Preprocessor). MarkCharm reads the files, identifies their extension natively, and inserts the values into the Macro Registry. To avoid collisions, the user can use as="namespace". The {#SET} directives operate in Phase 3 (Parser) and create global-scope variables for the document — see the dedicated section below.
Case number 998877/2026 is currently being processed by Tribunal de Contas da União. This information was loaded natively from the processo.json file, without the need for complex scripts. Document version 2.1 — classification: Internal Use.
Below is the information for the manager responsible for the proceedings:
Technical Explanation: Nested objects ({"gestor": {"nome": "..."}}) are recursively flattened by combining the original keys with an underscore character (_). Thus, gestor + nome dynamically becomes the macro \gestor_nome.
The contract linked to this procurement has CNPJ 12.345.678/0001-90 and was set at the value of R$ 1.500.000,00. The winning company of the Pregão Eletrônico was Cyber Dynamics Ltda (State Registration: 123.456.789.000), registered on 15/09/2026. This entire section was populated by empresa.yaml!
The audit report, issued by Mariana Souza (CRC: MG-123456/O), concluded that the status of the case is: Aprovado com Ressalvas (Code: PAR-2026-X8). This section was generated directly by reading the keys from auditoria.toml.
Note that MarkCharm automatically composes variable names for nested data using the underscore character (_).
Thanks to the power of the {$DATA} directive, arrays are also flattened seamlessly. Below, we use the dynamically generated macros (\lotes_0_descricao, etc.) inside a table and an official quadro:
Technical Explanation: When the source file contains a list (array), MarkCharm creates nominal indexers for each element (\\lista_0, \\lista_1). If the internal elements are data dictionaries, they are flattened again by concatenating the final key, yielding highly targeted macros such as \lotes_0_descricao.
| ID | Description | Quantity | Unit Price |
|---|---|---|---|
| 1 | Aquisição de Servidores | 5 | R$ 50.000,00 |
| 2 | Licenças de Software | 100 | R$ 1.200,00 |
| 3 | Suporte Técnico Mensal | 12 | R$ 15.000,00 |
| Information | Official Value (SSOT) |
|---|---|
Contractor CNPJ |
12.345.678/0001-90 |
Procurement Method |
Pregão Eletrônico |
Technical Opinion |
Aprovado com Ressalvas (PAR-2026-X8) |
Number of Lots |
3 (1 to 3) |
{#SET} and {#GET}In addition to external data loaded via {$DATA}, MarkCharm provides an inline document variable system — declared with {SET name value} and consumed with {GET name} anywhere in the file, regardless of order.
The four declarations used in this document (placed right after the pretext) were:
{#SET doc_version 2.1}
{#SET doc_classification Internal Use}
{#SET review_lead Carlos Henrique}
{#SET contract_scope Structured Data Integration}
Live expansion of values in this document:
| Variable Name | Expanded Value |
|---|---|
doc_version |
2.1 |
doc_classification |
Internal Use |
review_lead |
Carlos Henrique |
contract_scope |
Structured Data Integration |
The technical review of this document (2.1) was conducted by Carlos Henrique.
{#SET}/{#GET} and {$DATA}| Feature | {$DATA file} |
{SET name value} |
|---|---|---|
Phase |
Phase 1 — Preprocessor | Phase 3 — Parser |
Data Source |
External file (JSON/YAML/TOML) | Declared inline in .mc |
Variable Type |
Macro \\name |
Variable {GET varname} |
Quantity |
Unlimited (entire file) | Limited to what the author declares |
Forward Reference |
Not applicable | ✔ Supported |
Error if undeclared |
MCW-MAC-002 (warning) |
MCE-GET-001 (fatal) |
Global visibility and forward reference: A variable declared with {SET} at the end of the document can be consumed by {GET} at the beginning. The compiler performs a pre-scan (pass 0) before the main loop, ensuring that all variables are available regardless of order.
Declaring the same variable twice is a fatal error (MCE-SET-001). The first declaration prevails and compilation is aborted. Rename the variable or use {$DATA} with as="namespace" for multiple scopes.
The {$DATA} directive supports .json, .yaml, .yml, and .toml files. If you choose to use .toml, make sure the appropriate library is installed in your environment (or that you are using Python 3.11+).
Make sure the keys in your JSON file contain only valid characters for macro names (letters, numbers, and _). MarkCharm will report an error if an imported variable collides with or attempts to overwrite a protected structural macro.