Single Source of Truth (SSOT)

MarkCharm Team

September 11, 2026

Abstract

This document (Demo 02) demonstrates the power of the {$DATA} directive and compilation conditional blocks. Data files (.json, .yaml, .toml) are dynamically injected into the compiler. Simultaneously, it demonstrates how to use {#IFDEF} and {#IFNDEF} to create multiple versions of a single document (e.g. draft version with internal data vs clean final version) from a single source file.

Note

Technical Explanation: {$DATA} pragmas in the preamble intercept data files during Phase 1 (Preprocessor). MarkCharm reads the files, natively identifies their extension, and inserts values into the Macro Registry. To avoid collisions, users can use as="namespace". {#SET} directives operate in Phase 3 (Parser) and create global document variables.

1 Process and Management Data (JSON)

Source code:

Process number **\numero** is currently being handled at **\orgao**.
Document version **2.1** — classification: Internal Use.

Below is the information for the manager responsible:
- **Manager**: \gestor_nome
- **Tax ID**: \gestor_cpf

Rendered result:

Process number 998877/2026 is currently being handled at Tribunal de Contas da União. This information was loaded natively from processo.json without complex scripts. Document version 2.1 — classification: Internal Use.

Below is the information for the manager responsible:

Note

Technical Explanation: Nested objects ({"gestor": {"nome": "..."}}) are recursively flattened by combining original keys with an underscore (_). Thus, gestor + nome dynamically becomes the macro \gestor_nome.

2 Contracts and Associated Company (YAML)

Source code:

The contract linked to this bidding process has Tax ID **\contrato_cnpj**
and was set at a value of **\contrato_valor**.
The winning company of the **\licitacao_modalidade** was
**\empresa_razao_social** (State Reg: \empresa_inscricao_estadual),
opened on \licitacao_data_abertura.

Rendered result:

The contract linked to this bidding process has Tax ID 12.345.678/0001-90 and was set at a value of R$ 1.500.000,00. The winning company of the Pregão Eletrônico was Cyber Dynamics Ltda (State Reg: 123.456.789.000), opened on 15/09/2026. This entire section was powered by empresa.yaml!

3 Audit Report (TOML)

Source code:

The audit report, issued by **\auditoria_auditor_chefe**
(CRC: \auditoria_registro_crc), concluded that the process status is:
**\auditoria_parecer_status** (Code: \auditoria_parecer_codigo).

Rendered result:

The audit report, issued by Mariana Souza (CRC: MG-123456/O), concluded that the process status is: Aprovado com Ressalvas (Code: PAR-2026-X8). This section was generated directly by reading keys from auditoria.toml.

Note that MarkCharm automatically composes variable names for nested data using an underscore (_).

4 Lots Overview (Tables and Charts)

Thanks to the {$DATA} directive, arrays are also flattened seamlessly. Below, we use dynamically generated macros (e.g. {$DATA} flattens lotes[0].descricao → macro named lotes_0_descricao) inside a table and an official chart:

Note

Technical Explanation: When the source file contains a List (Array), MarkCharm creates nominal indexers for each element (e.g. lista[0] → lista_0, lista[1] → lista_1). If internal elements are data dictionaries, they are flattened again by appending the final key, yielding highly targeted macros (e.g. lotes[0].descricao → lotes_0_descricao).

4.1 Unit Pricing Table

Source code — The table block opens with `table [id] {title="..."} and each cell references a flattened macro from the JSON array:

```table [tab:precos] {title="Unit price composition based on JSON file"}
| ID | Description | Quantity | Unit Price |
| :---: | :--- | :---: | :--- |
| \lotes_0_id | \lotes_0_descricao | \lotes_0_quantidade | \lotes_0_valor_unitario |
| \lotes_1_id | \lotes_1_descricao | \lotes_1_quantidade | \lotes_1_valor_unitario |
| \lotes_2_id | \lotes_2_descricao | \lotes_2_quantidade | \lotes_2_valor_unitario |
```

Rendered result:

Table 1. Unit price composition based on JSON file
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

4.2 Unit Pricing Table (YAML Notation)

Source code — The same table using MarkCharm's native YAML frontmatter notation. Properties (title, source, notes) are declared as YAML keys before a --- separator, followed by the table content:

```table [tab:precos_yaml]
title: "Unit price composition based on JSON file"
source: "Data extracted from processo.json via {$DATA} directive"
notes: "Prices shown in Brazilian Real (BRL). Lot indexing starts at 0."
---
| ID | Description | Quantity | Unit Price |
| :---: | :--- | :---: | :--- |
| \lotes_0_id | \lotes_0_descricao | \lotes_0_quantidade | \lotes_0_valor_unitario |
| \lotes_1_id | \lotes_1_descricao | \lotes_1_quantidade | \lotes_1_valor_unitario |
| \lotes_2_id | \lotes_2_descricao | \lotes_2_quantidade | \lotes_2_valor_unitario |
```

Rendered result:

Table 2. Unit price composition based on JSON file
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
Source: Data extracted from processo.json via {$DATA} directive
Notes: Prices shown in Brazilian Real (BRL). Lot indexing starts at 0.
Note

Notation Comparison: The bracket notation ( {title="..."} ) is compact and suitable for inline declaration. The YAML frontmatter notation (with title:, source:, notes: before ---) is more readable for tables with multiple metadata fields and is the recommended form for complex tables.

4.3 Unit Pricing Table (Full YAML — Scaffold Notation)

Source code — The same table defined entirely in scaffold notation. No pipe syntax is needed — columns are declared with fields: and data rows with records:, all inside the fenced block:

```table [tab:precos_scaffold] {title="Unit price composition (full scaffold)"}
dataset:
  orientation: line
  fields:
    + id:
        title: ID
        align: center
    + descricao:
        title: Description
        align: left
    + quantidade:
        title: Quantity
        align: center
    + valor:
        title: Unit Price
        align: left

  records:
    + id: \lotes_0_id
      descricao: \lotes_0_descricao
      quantidade: \lotes_0_quantidade
      valor: \lotes_0_valor_unitario

    + id: \lotes_1_id
      descricao: \lotes_1_descricao
      quantidade: \lotes_1_quantidade
      valor: \lotes_1_valor_unitario

    + id: \lotes_2_id
      descricao: \lotes_2_descricao
      quantidade: \lotes_2_quantidade
      valor: \lotes_2_valor_unitario
```

Rendered result:

Table 3. Unit price composition (full scaffold)
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
Note

Full YAML Advantage: The scaffold notation defines columns (fields:) and rows (records:) entirely in structured YAML. Each field declares its title and align. Each record maps field names to values. This is ideal for complex, data-driven tables with multi-line content, computed cells, or programmatic generation.

4.4 Contract Summary Chart

Source code — The chart block uses `quadro to produce a formal numbered chart:

```quadro [quadro:resumo] {title="Contract and Audit Summary"}
| Information | Official Value (SSOT) |
| :--- | :--- |
| **Contracted Tax ID** | \contrato_cnpj |
| **Modality** | \licitacao_modalidade |
| **Technical Opinion** | \auditoria_parecer_status (\auditoria_parecer_codigo) |
| **Quantity of Lots** | 3 (1 to 3) |
```

Rendered result:

Chart 1. Contract and Audit Summary
Information Official Value (SSOT)

Contracted Tax ID

12.345.678/0001-90

Modality

Pregão Eletrônico

Technical Opinion

Aprovado com Ressalvas (PAR-2026-X8)

Quantity of Lots

3 (1 to 3)

5 Document Variables: {#SET} and {#GET}

In addition to external data loaded via {$DATA}, MarkCharm offers an inline document variable system — declared with {SET name valor} and consumed with {GET name} anywhere in the file, regardless of order.

The four declarations used in this document (made right after the preamble) were:

{#SET doc_versao 2.1}
{#SET doc_classificacao Internal Use}
{#SET responsavel_revisao Carlos Henrique}
{#SET escopo_contrato Structured Data Integration}

Live expansion of values in this document:

Source code:

| Variable Name | Expanded Value |
| :--- | :--- |
| `doc_versao` | 2.1 |
| `doc_classificacao` | Internal Use |
| `responsavel_revisao` | Carlos Henrique |
| `escopo_contrato` | Structured Data Integration |

Rendered result:

Variable Name Expanded Value
doc_versao 2.1
doc_classificacao Internal Use
responsavel_revisao Carlos Henrique
escopo_contrato Structured Data Integration

The technical review of this document (2.1) was conducted by Carlos Henrique.

6 Conditional Versions (Draft vs Production)

The text below demonstrates conditional blocks for emitting clean (public) or complete (restricted) reports.

Source code:

{#IFDEF DRAFT}
> [!WARNING]
> This document is a **DRAFT** version containing confidential
> data of Manager \gestor_nome (Tax ID \gestor_cpf).
> Do not distribute publicly.
{#ENDIF}

{#IFNDEF DRAFT}
This is the **FINAL (Public)** version of the document.
Sensitive data was automatically removed during compilation.
{#ENDIF}

Rendered result (current compilation):

This is the FINAL (Public) version of the document. Sensitive data was automatically removed during compilation.


Note

Usage Notes and Requirements

  1. Multiple Data & Conditional Compilation: Artifact centralizing data (.json, .yaml, .toml), variables, and conditional control (-D DRAFT).
  2. Variables ({#SET}/{#GET}): The parser supports forward-referencing, meaning variables can be defined at the end and referenced at the top of the file.
  3. Data Format Support: {$DATA} directive supports .json, .yaml, and .toml files with automatic flattening, building underscore-delimited keys.