TagsAtStartOfFlowContainerWithPathString method
Implementation
@internal
List<String> TagsAtStartOfFlowContainerWithPathString(String pathString) {
var path = Path(pathString);
// Expected to be global story, knot or stitch
Container flowContainer = contentAtPath(path).container!;
while (true) {
var firstContent = flowContainer.content[0];
if (firstContent is Container) {
flowContainer = firstContent;
} else {
break;
}
}
// Any initial tag objects count as the "main tags" associated with that story/knot/stitch
bool inTag = false;
List<String> tags = [];
for (var c in flowContainer.content) {
var command = asOrNull<ControlCommand>(c);
if (command != null) {
if (command.commandType == CommandType.BeginTag) {
inTag = true;
} else if (command.commandType == CommandType.EndTag) {
inTag = false;
}
} else if (inTag) {
var str = asOrNull<StringValue>(c);
if (str != null) {
tags.add(str.value);
} else {
Exception(
'Tag contained non-text content. Only plain text is allowed when using globalTags or TagsAtContentPath. If you want to evaluate dynamic content, you need to use story.Continue().');
}
}
// Legacy Tag ( ink version 20 )
else if (c is Tag) {
tags.add(c.text);
}
// Any other content - we're done
// We only recognise initial text-only tags
else {
break;
}
}
return tags;
}