#include <iostream>
#include <string>
int main() {
std::string name;
std::cout << "What's your name? ";
std::cin >> name;
std::cout << "Hello, " << name << "!\n";
}Programming lessons in Markdown
Lessons that compile.
Write the lesson in Markdown. Every code block gets a ▶ that compiles with the real g++ and shows the output in a terminal, right there, on the projector.
$ trunade lesson.mdReading from the keyboard
Press ▶ and type your name in the terminal.
The lesson is a file.
Plain Markdown, in your editor. Save it and the page updates.
lesson-02.md
## Reading from the keyboard
Use `std::cin` to read from standard input.
```cpp
#include <iostream>
int main() {
int a, b;
std::cin >> a >> b;
std::cout << a + b << "\n";
}
```
```stdin
2 40
```- Whole programs
- Each block has its own main() and is compiled from scratch, like in an exam.
- Real input
- A stdin block shipped with the lesson, expected output with a judge verdict, or interactive cin in the terminal.
- Errors are content
- Full compiler errors, signals, time limits and exit codes.
What comes built in.
- C++, C and Python
- Other languages through configuration, with any compiler and flags.
- Hidden template
- Declare #include and using namespace std once; each block shows only what matters.
- Test cases
- stdin/expected pairs with ✓ or ✗ like a judge: passed the sample, failed the edge case.
- Math and diagrams
- LaTeX and Mermaid rendered locally.
- Questions and steps
- Quiz blocks and exercises with statement, hint and a solution that runs.
- Made for the projector
- T for the outline, space for the next section, Z zooms a block, F for full screen.
- Run all
- R runs every block with fixed input and points at what broke, before you walk into class.
- PDF and HTML
- Export the lesson with its outputs; the HTML opens anywhere and replays each run on ▶.
- Research log
- A local, anonymous log of runs, errors, answers and sections, to study the lesson.
- Edit fearlessly
- Change code during class; the file stays the same.
- Offline
- One local binary. No CDN, no account, no cloud.
- Your fonts
- Theme, width and title, text and code fonts, kept for every lesson.
What about Jupyter?
Great when state across cells is the point: data, plots, exploration. A C++ lesson asks for something else.
| Trunade! | Jupyter | |
|---|---|---|
| Block | a whole program, with main() | a cell that continues earlier state |
| Compiler | the real one, with your flags | the kernel's (C++ interpreted) |
| Input | interactive terminal or fixed stdin | limited |
| Expected output | a verdict per case, like a judge | by hand |
| File | plain Markdown | JSON with embedded outputs |
Install and run.
$ brew install gcc # g++-16 on macOS
$ ./install.sh
$ trunade lesson.md