summaryrefslogtreecommitdiff
path: root/README.md
blob: 4b74016d99575ff735ffa2c8a700e8e3114c61d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# MarkDialog

> Write your story with Markdown!

## Some Ramblings

This is a personal learning project of mine. To quickly achieve the desired effect, the project experimentally uses **Vibe Coding**.

## Introduction

MarkDialog is a **paradigm for writing textual narratives**. It defines how to use **Markdown** to describe dialogue for text adventure games.

It allows you to:

- Use **level-six headings** to represent characters.
- Use **headings** to represent paragraphs.
- Use **hyperlinks** to represent jumps.
- Use **code blocks** to control speed, visuals, and interact with game content.

> [!NOTE]
> If you want to learn about MarkDialog syntax, click here.
>
> [MarkDialog Example Article](#example-article)

## Toolchain

MarkDialog provides a compilation tool `mdialogc`, which can compile your **Markdown** files into an intermediate language for fast playback or execution on any frontend.

```bash
# Execution, will output YourMarkdown.dialog
mdialogc -i YourMarkdown.md
```

Currently supported frontends:

- [Rust](#rust-example)

## Other

#### Example Article

```markdown
# Dialogue

###### Alice

Good morning, Bob.

Have you had breakfast?

- [Of course I have!](#Bob-has-had-breakfast)
- [Not yet.](#Bob-has-not-had-breakfast)
- [I'm not hungry.](#Bob-is-not-hungry)

## Bob-has-had-breakfast

###### Bob

I certainly **had breakfast**!

###### Alice

*Oh.* I was hoping you'd join me.

###### Narrator

(Story ends)

## Bob-has-not-had-breakfast

###### Bob

Not yet.

###### Alice

[Great! Want to go get breakfast together?](#Alice-asks-to-eat-breakfast-together)

## Bob-is-not-hungry

###### Bob

*I'm actually not hungry*?

###### Alice

Never mind then, what a pity today. (*muttering quietly*)

###### Narrator

(Story ends)

## Alice-asks-to-eat-breakfast-together

###### Bob

Let me think...

- Let's go!
- No, I'm [not hungry](#Bob-is-not-hungry)

###### Alice

Great! Let's go!

###### Narrator

(And so Bob and Alice had breakfast together)

(Story ends)
```

#### Rust Example

```toml
# Cargo.toml
[package]
name = "your_proj"
version = "0.1.0"
edition = "2024"

[dependencies]
markdialog = "0.1"
```

```rust
// main.rs
use markdialog::{markdialog, step};

markdialog!(my = "alice_and_bob.dialog");

fn main() {
    let my_step = my::get_step(step!("Bob-has-had-breakfast")).unwrap();
    let sentence = my_step.sentences[0];
    println!(
        "{} said : \"{}\"",
        sentence.character.unwrap_or_default(),
        sentence
            .content_tokens
            .iter()
            .map(|token| match token {
                my::Token::Text(t) => t,
                my::Token::BoldText(t) => t,
                my::Token::ItalicText(t) => t,
                my::Token::BoldItalicText(t) => t,
                _ => "",
            }
            .to_string())
            .collect::<Vec<String>>()
            .join("")
    )
}
```