A foreach based on a list within a text field?

Is there a way to go through a list within a file with a foreach?

Let’s say I have a “Related” field in my file, containing a markdown-based list; is there a way to do a foreach targetting each element of this list?

Aiming a little bligger, is there a way to do a foreach within a foreach in a file?
I’m thinking of creating a visual novel engine based on jQuery (for front end) and Kirby (for back end). Ideally, jQuery would enable navigating between content arrays stored in a Kirby file (each array being displayed according to a specific template). I know how to do this with separate files (foreach children does the trick) or with an XML file, but I’d like to do it within a single file (because the other options are much less practical than I’d like).

Structurally the file might look like this:

(01): Speaker: Robert
Text: Hi, how are you?

(02): Speaker: ???
Text: I’m fine, what about you?

So here, the first array would be [Speaker: “Robert”; Text: “Hi, how are you?”] and the second would be [Speaker: “???”; Text: “I’m fine, what about you?”]. (Or alternatively I’d have an array containing the two arrays I just described.)

Is this feasible? I’m assuming parsing would need to be involved, but I have zero experience with this.


Okay, this is probably the key I was looking for. I’ll do some experiments with it.