blob: 0cb81f4b7d6d07ac658ee185854f4b172e32f562 (
plain)
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
|
## Format
Here is a list of lists
representing a slightly augmented
deck of cards
(basically the heckadeck):
```
:: suit
spades
hearts
clubs
diamonds
acorns
clouds
swords
planets
:: face
beast
thief
jack
queen
king
:: number
zero
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
:: special
crone
joker
watcher
traveler
:: card
[[number]]
[[face]]
:: draw
[[card]] of [[suit]]
[[special]]
```
A list title appears on a line by itself,
preceded by a double colon (::)
and at least one space.
A list title can contain alphabet characters and a dash.
Following the list title are list items,
each on its own line.
A list item may be (or contain) a reference
to a list title in double brackets.
e.g. [[list-title]]
Blank lines are ignored.
## Usage
Pass the filename of a file of lists formatted in this way
to `create_corpus`
and get a "corpus" in return.
A corpus is just a deserialized fennel table
of list titles and list items.
Then pass the corpus to `flatten`
along with a string or a list to serve as the "origin".
In this case if you pass `corpus.draw`,
then `flatten` will return a random selection from `:draw`,
expanding references along the way:
- beast of spades
- five of hearts
- jack of acorns
- watcher
- three of planets
- beast of clubs
Read and run `story.test.fnl` for an example.
## Inspiration
This is inspired by [tracery][1]
and [perchance][4]
and the [List to HTML Generator][5],
and is similar to [twee][2] format.
In fact,
with just a little modification,
you can use this story file
to generate tracery output
in a twine story
using [trice][3].
[1]: https://github.com/galaxykate/tracery
[2]: https://twinery.org/cookbook/terms/terms_twee.html
[3]: https://github.com/incobalt/Trice
[4]: https://perchance.org/
[5]: https://slightadjustments.blogspot.com/p/generator.html
|