Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harlowe StoryMap missing arrow links between passages when changers are used #154

Open
hawkerm opened this issue Jan 4, 2024 · 4 comments

Comments

@hawkerm
Copy link

hawkerm commented Jan 4, 2024

I noticed with Harlowe, if not using straight links to passages [[Text|Passage]] and things like:

  • (goto:)
  • (click-goto:)
  • (link-goto:)
  • (link-reveal-goto:)
  • (mouseover-goto:)
  • (mouseout-goto:)

Then the StoryMap graph doesn't show these as links to between the passages in the information sidebar nor with an arrow.

Makes it a bit misleading when there's still a connection between the passages. Would be nice if these could be detected and added to the StoryMap as well.

Related/similar to #76 for SugarCube I think?

@Tranberry
Copy link
Contributor

yes the workaround for SC is to have the twine passage link in a "comment", not sure if that is possible in Harlowe.

<!--[[Text|Passage]]--> something like this.

@hawkerm
Copy link
Author

hawkerm commented Jan 5, 2024

Thanks @Tranberry, looks like the same trick works for Harlowe:

<!--[[Text->Passage]]-->

Would be nice to not have to double-manage and have it automatically picked up still though.

Looks like this may be one of the items on the long todo list in the story map source: https://github.com/cyrusfirheir/twee3-language-tools/blob/master/story-map/todo.md

Poking around, looks like this is the function below which does the detection of the simple links and would need to be updated for the various function patterns for the different flavors:

export function getLinkedPassageNames(passageContent: string): string[] {
const parts = passageContent.split(/\[(?:img)?\[/).slice(1);
return parts.filter((part) => part.indexOf(']]') !== -1).map((part) => {
const link = part.split(']').shift() as string;
if (link.includes("->")) return (link.split("->").pop() as string).trim();
else if (link.includes("<-")) return (link.split("<-").shift() as string).trim();
else return (link.split('|').pop() as string).trim();
});
};

Which is called just below in the same file to send this info from the backend to the frontend:

linksToNames = getLinkedPassageNames(passageContent);
}
return {
origin: passage.origin,
range: {
startLine: passage.range.start.line,
startCharacter: passage.range.start.character,
endLine: passage.range.end.line,
endCharacter: passage.range.end.character,
},
stringRange: {
start: passage.stringRange.start,
endHeader: passage.stringRange.endHeader,
end: passage.stringRange.end
},
name: passage.name,
tags: passage.tags,
meta: passage.meta,
linksToNames,

This eventually creates the LinkedPassage type in the Story Map here via this function:

export const linkPassage = (passage: Passage, allPassages: Passage[]): LinkedPassage => {
return Object.assign(passage, {
linksTo: allPassages.filter((otherPassage) => passage.linksToNames.includes(otherPassage.name)),
linkedFrom: allPassages.filter((otherPassage) => otherPassage.linksToNames.includes(passage.name)),
});
}

Not sure of all the various patterns across flavors myself, nor if there's a variable somewhere that stores whatever the editor is set to which could be used here to optimize it. Though, hopefully pointing this out helps someone know how to better fix this scenario. 😊

I think detecting SugarCube and Harlowe could be fairly similar like optional starting ( for Harlowe, some text for other variants, then the goto then an optional : for Harlowe, then the passage name at the end...

Doc links for these special formats:

@kilogold
Copy link

+1

Without arrows for goto:, improvements to the editor view become less useful/important.
It seems like goto: is the predominant use case in Twine, because only employing simple links can be approximated in almost any tool, even Google Forms.

@Mermothle
Copy link

Mermothle commented Sep 2, 2024

+1

Doesn't show arrows when using "link" macro in SugarCube either. Or "textbox" forwarding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants