Nested Macro System (MacroRegistry)

MarkCharm Compiler Engineering

Abstract

This demonstration showcases the recursive expansion architecture of the MacroRegistry in MarkCharm. It demonstrates macro composition across three levels (Atoms, Molecules, and Organisms), protection against infinite recursion, and transparent injection into tables and lists.

1 Technical Demonstration: Nested Macro System (MacroRegistry)

1.1 Overview of the Expansion Architecture

The architecture of MacroRegistry in MarkCharm performs depth-first recursive scans for the expansion of commands adhering to native LaTeX notation (\\newcommand{name}{body}). When a high-level composite macro (Organism) is invoked, the compiler injects the derived template into the document stream and subjects the text to successive scanning passes (_depth + 1) as long as mutations yield results.

The process is shielded against infinite expansion loops by a hard safety limit (_MAX_EXPANSION_DEPTH = 10), emitting the warning diagnostic MCW-MACRO-001 if a circular dependency is detected.

[ Invocation: - \CartaoIdentidade{Alan Turing}{AT}{Chief Scientist} ]
               │
               ▼  (Pass 1: Organism Expansion)
[ - \PerfilCapa{Alan Turing}{AT} (Role: `Chief Scientist`) ]
               │
               ▼  (Pass 2: Molecule Expansion)
[ - \DestacaNome{Alan Turing} (\EstiloSigla{AT}) (Role: `Chief Scientist`) ]
               │
               ▼  (Pass 3: Atom Expansion)
[ - \textbf{Alan Turing} (\textit{AT}) (Role: `Chief Scientist`) ]
               │
               ▼  (Pass 4: AST Injection & HTML Formatting as List)
[ <li><strong>Alan Turing</strong> (<em>AT</em>) (Role: <code>Chief Scientist</code>)</li> ]

1.2 Demonstration of Organism Components

1.2.1 Corporate Identity Cards

3 distinct levels of cascading macroscopic complexity were defined in the preamble of this document. Simple invocation of the master macro in the body of the document recursively expands all of its sub-components:

Código de Invocação:

- \CartaoIdentidade{Alan Turing}{AT}{Chief Computational Scientist}
- \CartaoIdentidade{Ada Lovelace}{AL}{Analytical Architecture Founder}
- \CartaoIdentidade{Grace Hopper}{GH}{Admiral & Compiler Pioneer}

Resultado Renderizado:

1.2.2 Technical Service Sheets

Combining badges and metrics into unified components:

Código de Invocação:

- \FichaTecnicaServico{CORE}{v3.4.1}{99.99%}{Production}
- \FichaTecnicaServico{AUTH}{v2.1.0}{99.95%}{Staging}

Resultado Renderizado:

1.2.3 Audit Logs

Complex reporting components rendered cleanly:

Código de Invocação:

- \RegistroAuditoria{Deployment}{2026-08-30}{Alan Turing}{AT}{SUCCESS}
- \RegistroAuditoria{Security Audit}{2026-08-29}{Grace Hopper}{GH}{VERIFIED}

Resultado Renderizado:


2 Self-Contained Media Features Demonstration

3 Introduction

This demonstration presents the capability of embedding multimedia files and images directly into the HTML document generated by the MarkCharm compiler. All local media is transparently converted into Base64 Data URIs, enabling the distribution of a single, fully self-contained and auditable .html file.

As demonstrated in the following data:tions, direct cross-references can be made to sec. 4, Fig. 1, sec. 4, Fig. 2, sec. 5, Audio 1, sec. 6, Video 1, and sec. 7, Object 1.

4 Repository Images and Scaling

Images continue to be handled by the figure presentation block, supporting optional relative width parameters (width='40%', width='85%'), generating automatic numbering and responsive legibility.

Fig. 2 demonstrates the use of high-resolution artwork from the repository collection, scaled to 85% of paragraph length:

Figure 2. The School of Athens (Fresco by Raphael in the Vatican)
The School of Athens (Fresco by Raphael in the Vatican)
Source: Wikimedia Commons / Cultural Collection (assets/images/Escola_de_Atenas_Vaticano.jpg).
Notes: High-definition JPEG image encapsulated directly in the HTML body.

5 Audio Resources

For audio file inclusion, use the audio block pointing to assets/audio/ with optional dimension adjustments (width='70%'). The native HTML player embeds playback controls.

Audio 1. Opening Audio Jingles
Source: Mozilla Developer Network (MDN) / MarkCharm Audio Collection (assets/audio/audio_exemplo.mp3).
Notes: MP3 file encoded as Base64 Data URI.

As seen in audio 1, the audio player is rendered with a responsive width of 70% and support for source and observation sub-blocks.

6 Video Resources

The video block allows embedding video elements (.mp4, .webm, .ogv) stored in assets/videos/, ensuring dynamic presentations remain saved within the report itself.

Video 1. Interactive Compilation Demo
Source: W3Schools (Big Buck Bunny) / Video Collection (assets/videos/video_exemplo.mp4).

7 Encapsulated Objects (PDF and Documents)

External documents like PDFs or spreadsheets stored in assets/documents/ can be embedded via the object block, displaying the browser's native viewer interface.

Object 1. Complementary Report in PDF Format
Source: W3C (Web Accessibility Initiative) / Document Collection (assets/documents/documento.pdf).

8 Conclusion

MarkCharm's self-contained architecture ensures complete portability of generated documents without needing external asset bundlers or resource managers.


Note

Usage Requirements & Technical Caveats

  1. Self-Contained Mode (\embed_media{true}): Converts images, audio, video, and PDFs into Base64 Data URIs, increasing final HTML file size by ~33%.
  2. Reading Performance: Suitable for reports and deliverables requiring complete web server independence.