September 11, 2026
Abstract
This demonstration showcases MarkCharm's polyglot execution engine for dynamic document automation. It illustrates native script compilation across Python, JavaScript (Node.js), Julia, and GNU Bash. The demo highlights the duality between standard verbatim stdout capture and raw Markdown/MarkCharm markup parsing (parse=true) for dynamic table and list generation.
MarkCharm is more than just a markup language — it's a polyglot programmable environment for generating technical documents. Scripts written in Python, JavaScript, Julia, and Bash can be executed natively during compilation to compute data, inspect environments, and dynamically generate document elements.
Python scripts can perform computations, read block attributes, and emit native document structures.
Source Code:
import math
print(f"Executor: Python 3")
print(f"Engine: {attrs['author']} v{attrs['version']}")
print(f"Calculation: sqrt(2) = {math.sqrt(2):.4f}")
Rendered Result:
Executor: Python 3
Engine: MarkCharm v1.0
Calculation: sqrt(2) = 1.4142
parse=true)Using parse=true, Python stdout is parsed directly into native tables and nested enumerations:
Source Code:
print("| Step | Value | Squared |")
print("| :---: | :---: | :---: |")
for i in range(1, 4):
val = i * 10
print(f"| {i} | {val} | {val**2} |")
print("")
print("- Python Workflow Tasks")
for idx, topic in enumerate(["Data Ingestion", "Transformation", "Export"], 1):
print(f" {idx}. Phase {idx}: {topic}")
Rendered Result:
| Step | Value | Squared |
|---|---|---|
| 1 | 10 | 100 |
| 2 | 20 | 400 |
| 3 | 30 | 900 |
JavaScript scripts run inside Node.js, accessing block attributes via the attrs object.
Source Code:
console.log(`Executor: JavaScript (Node.js)`);
console.log(`Engine: ${attrs.author} v${attrs.version}`);
console.log(`Calculation: sqrt(2) = ${Math.sqrt(2).toFixed(4)}`);
Rendered Result:
Executor: JavaScript (Node.js)
Engine: MarkCharm v1.0
Calculation: sqrt(2) = 1.4142
parse=true)Using parse=true, JavaScript stdout is parsed directly into native tables and nested enumerations:
Source Code:
console.log("| Step | Value | Squared |");
console.log("| :---: | :---: | :---: |");
for (let i = 1; i <= 3; i++) {
let val = i * 10;
console.log(`| ${i} | ${val} | ${val * val} |`);
}
console.log("");
console.log("- JavaScript Workflow Tasks");
["Data Ingestion", "Transformation", "Export"].forEach((topic, idx) => {
console.log(` ${idx + 1}. Phase ${idx + 1}: ${topic}`);
});
Rendered Result:
| Step | Value | Squared |
|---|---|---|
| 1 | 10 | 100 |
| 2 | 20 | 400 |
| 3 | 30 | 900 |
Julia scripts provide high-performance scientific execution with safe Base64 attribute injection.
Source Code:
println("Executor: Julia")
println("Engine: ", attrs["author"], " v", attrs["version"])
println("Calculation: sqrt(2) = ", round(sqrt(2), digits=4))
Rendered Result:
Executor: Julia
Engine: MarkCharm v1.0
Calculation: sqrt(2) = 1.4142
parse=true)Using parse=true, Julia stdout is parsed directly into native tables and nested enumerations:
Source Code:
println("| Step | Value | Squared |")
println("| :---: | :---: | :---: |")
for i in 1:3
val = i * 10
println("| ", i, " | ", val, " | ", val^2, " |")
end
println("")
println("- Julia Workflow Tasks")
topics = ["Data Ingestion", "Transformation", "Export"]
for (idx, topic) in enumerate(topics)
println(" ", idx, ". Phase ", idx, ": ", topic)
end
Rendered Result:
| Step | Value | Squared |
|---|---|---|
| 1 | 10 | 100 |
| 2 | 20 | 400 |
| 3 | 30 | 900 |
Bash scripts interact with environment variables and system tools, receiving attributes via MC_ATTR_*.
Source Code:
echo "Executor: GNU Bash"
echo "Engine: $MC_ATTR_AUTHOR v$MC_ATTR_VERSION"
echo "Calculation: sqrt(2) = 1.4142"
Rendered Result:
Executor: GNU Bash
Engine: MarkCharm v1.0
Calculation: sqrt(2) = 1.4142
parse=true)Using parse=true, Bash stdout is parsed directly into native tables and nested enumerations:
Source Code:
echo "| Step | Value | Squared |"
echo "| :---: | :---: | :---: |"
for i in 1 2 3; do
val=$((i * 10))
sq=$((val * val))
echo "| $i | $val | $sq |"
done
echo ""
echo "- Bash Workflow Tasks"
topics=("Data Ingestion" "Transformation" "Export")
idx=1
for topic in "${topics[@]}"; do
echo " $idx. Phase $idx: $topic"
idx=$((idx + 1))
done
Rendered Result:
| Step | Value | Squared |
|---|---|---|
| 1 | 10 | 100 |
| 2 | 20 | 400 |
| 3 | 30 | 900 |
The content generated by execute blocks is inserted directly into the final document, ensuring technical reports stay synchronized with actual systems. See Subsection 1.1, Subsection 1.2, Subsection 1.3, and Subsection 1.4 for polyglot execution examples.
Os arquivos abaixo (incluídos modularmente) demonstram outras técnicas de automação via macros nativas (MacroRegistry) e scripts inline.
The most basic way to use macros is with numeric positional parameters, replacing old syntax (#1) with explicit brace syntax (#{1}).
Definition Code:
\newcommand{saudacao}{Hello, #{1}! Welcome to MarkCharm.}
Invocation Code and Result:
\saudacao{User}
\saudacao{Developer}
Hello, User! Welcome to MarkCharm.
Hello, Developer! Welcome to MarkCharm.
We can create more descriptive macros by defining named parameters. It is also possible to assign default values when parameters are omitted during invocation.
Definition Code:
\newcommand{alerta}[tipo=info, cor=blue]{
<div style="border-left: 4px solid #{cor}; padding: 10px; background: #f9f9f9; margin-bottom: 15px;">
<strong>#{tipo}:</strong> #{1}
</div>
}
When calling the macro without named parameters, it will use the defaults (info and blue):
Invocation Code and Result:
\alerta{System initialized successfully.}
We can override parameters (with or without internal quotes):
Invocation Code and Result:
\alerta[tipo=Warning, cor=orange]{Disk space is running low.}
\alerta[tipo="Critical Error", cor=red]{Database connection failed!}
When passing parameters containing commas, protect them with double quotes in the invocation; otherwise the interpreter would split arguments at the wrong location. MarkCharm automatically strips surrounding quotes during interpolation.
Definition Code:
\newcommand{destaque}[texto="No text", destaque_bg=yellow]{
<span style="background-color: #{destaque_bg}; padding: 2px 4px; border-radius: 4px;">#{texto}</span>
}
Invocation Code and Result:
\destaque[texto="This text contains commas, spaces and punctuation", destaque_bg=lightgreen]
This text contains commas, spaces and punctuation
Thanks to parser robustness (support for up to 3 levels of nesting), complex document commands can be invoked and macros passed inside other directives.
Definition Code:
\newcommand{cartao_perfil}[nome=Anonymous, ocupacao="Unspecified role", avatar="default.png"]{
<div class="perfil-card" style="display: flex; gap: 15px; border: 1px solid #ccc; padding: 15px;">
<img data="#{avatar}" width="50" height="50" style="border-radius: 50%;">
<div>
<h3 style="margin: 0;">#{nome}</h3>
<p style="margin: 5px 0 0 0; color: #666;">#{ocupacao}</p>
</div>
</div>
}
Invocation Code and Result:
\cartao_perfil[nome="John Doe", ocupacao="Software Engineer, AI Specialist", avatar="https://via.placeholder.com/50"]
\cartao_perfil[nome="Jane Smith, PhD", ocupacao="Scientific Researcher"]
Software Engineer, AI Specialist
Scientific Researcher
Technical Caveats
The new #{...} delimiter should be preferred in all constructs to avoid conflict with hexadecimal color codes (e.g. #666).
Strings passed to named parameters containing commas (,) MUST use double quotes.
The #{...} delimiter was engineered not to conflict with math environments. Engines like MathJax and KaTeX internally use old syntax (#1) and commands with backslashes in their names. MarkCharm safely ignores definitions whose macro syntax includes a backslash (\name), passing it intact to the math processor.
Additionally, if you need to write programming code (like Ruby or MyBatis SQL queries) inside a MarkCharm macro and literally generate #{...} syntax, simply escape it with a backslash \#{...}.
$$
\newcommand{\vetor}[1]{\mathbf{#1}}
\vetor{v} = \vetor{x} + \vetor{y}
$$
Abstract
This demonstration illustrates compile-time computational execution blocks (execute{lang=python} and execute{lang=bash}). It showcases passing attributes to scripts, programmatic table/callout generation, and host operating system integration.
MarkCharm is more than a markup language — it is a programmable environment for technical document generation.
We can automate data acquisition and formatting directly inside the document.
> [!TIP]
> Data generated on: 11/08/2026 10:00:00
Document parameters can be passed directly to the script via block attributes.
- **Safety Threshold**: 75.0%
- **Current State**: Critical
- **Alert**: Value exceeds configured safety margin.
The compiler can also interact with the operating system environment.
The host system is operating in the following environment:
% **Kernel**: 6.8.0-generic
% **Hostname**: markcharm-node
% **Uptime**: up 10 hours, 30 minutes
MacroRegistry)Whenever we invoke the command in the main document:
\PerfilFuncionario{John Doe}{15/04/1985}{Software Engineer}
{{ ... }}
The table is physically reproduced, with all its Design Token processing inheriting the primary styling of this document.
We can instantiate the component as many times as needed:
\PerfilFuncionario{Mary Smith}{22/11/1990}{Senior Partner & Legal Counsel}
\PerfilFuncionario{Carlos Drummond}{31/10/1902}{National Poet}
\PerfilFuncionario{ Claude Shannon }
{ April 30, 1916 } { American mathematician, electrical engineer and cryptographer, known as "the father of information theory" }
Usage Requirements & Technical Caveats
macros.mc) with positional arguments #{1}, #{2}, etc., and included via {$INCLUDE}.Requirements and Technical Caveats
python3, node, julia, bash).{#EXEC}): Dynamic execution blocks must be explicitly allowed by the document author using the {#EXEC} pragma in the file preamble, or bypassed via CLI using --unsafe.stdout and stderr. To ensure successful markup injection when using parse=true, verify that no verbose error messages or unformatted text streams pollute the expected output structure.