Website Hyperlinks for TADS 3 in Parchment?

So I know that clickable links for actions are not available in Parchment because that’s specifically an HTML TADS thing.

However, in the credits of my game, I’ve included links to people’s pages, and in the in-progress-post-comp version I have links going to the map, and also two recommended offline interpreters (so the player can have the sound and music that plays in the game).

Parchment seems to also disable actual off-site links, too. So the links in the credits are dead, and the links to two recommended interpreters are dead as well.

Is there a way to make it so href links that start with http or https don’t get scrubbed in Parchment? I can make do without clickable action links, but having missing website links causes a lot of problems that I don’t really have a solution for, on the game file side of things.

Alternatively, I guess I can just print out the actual URL as plain text, if the game detects an interpreter that isn’t compliant with HTML TADS. I feel like players would find that really awkward, particularly on screen readers, though. I don’t really know what else to do, though.

Thanks for your time!

4 Likes

That’s what my games do. I agree, it’s not optimal.

2 Likes

Might make a top-level function that formats links in different ways, based on if the interpreter is HTML-compliant or not. Might also check if Gargoyle and others handle website links, even if they don’t handle clickable actions.

Just occurred to me that if I get complacent because Parchment handles website hyperlinks, even if it doesn’t register as HTML-compliant, then I might inadvertently screw over Gargoyle players…

1 Like

Okay, so it turns out Gargoyle also does not support website hyperlinks.

So…

…maybe I’ll stop bugging @Dannii about Parchment compatibility and use Jim’s strategy, lol…

1 Like

UPDATE: So this is how it looks in Gargoyle, using a little subsystem I whipped up in a few minutes.

And this is how it looks in QTADS:

Screenshot from 2023-06-17 17-07-27

Basically, I store each hyperlink in an object, and then have a method for HTML TADS printing-in-place, and a backup method that prints it in “footer form” if the interpreter is not HTML-compliant.

class CompULR: object {
    baseHeader = ''
    baseText = 'Click here'
    baseTail = ''
    altText = (baseText)
    name = 'Link to demo'
    url = './link/here'
    clickURL = (url)

    printBase() {
        if (outputManager.htmlMode) {
            say(baseHeader);
            say('<a href="' + clickURL + '">');
            say(baseText);
            say('</a>');
            say(baseTail);
        }
        else {
            say(altText);
        }
    }

    printFooter() {
        if (outputManager.htmlMode) return;
        say('<.p>\t<b>' + name + ':</b>\n');
        say('<tt>' + url + '</tt><.p>');
    }
}
9 Likes

interesting formatting trick :slight_smile:

Best regards from Italy,
dott. Piergiorgio.

2 Likes

Whoa… It scrubs all links? This is not good for my project.

Is there a way around it? It’d be a major stumbling block if players have to copy-paste links or any such shenanigans.

(EDIT: Ah, Parchment doesn’t do HTML TADS at all. I wondered why things were so weird. Ah nuts…)

2 Likes

Thank you :grin: it means that if I mention a URL in multiple places, and the URL changes in the future, then I only need to update it in one place for easier bugfixing!

1 Like

Neither does Gargoyle, which is another popular interpreter out there. All my website hyperlinks disappear there, too.

Honestly I’m kinda kicking myself a bit because I made an effort to dynamically rearrange stuff in my game to accommodate non-HTML interpreters. The goal I had written for myself was “This should be fun, even in a basic text terminal”.

While I knew the clickable action links would be gone, it never occurred to me to check the hyperlinks in the credits. Y’know, the place where I shout out all the cool stuff that my testers are working on.

But now I know, and I’m fixing this for the post-comp version.

3 Likes

Okay, I’ve managed to hack together a truly unholy approach. I have a hacks.js loaded after everything in Parchment. Using jQuery it finds certain text strings and replaces them as the game plays. This is likely neither performant nor robust. May XYZZY have mercy on my soul.

For example MYWEBSITE will be replaced with the clickable <a href="https://brettwitty.net">My site</a>. You can also clean up things like <hr/> being mangled into many hyphens, and then unmangle them into <hr/> again.

While it doesn’t fix the lovely aHref click-to-run-command helpers that I used for a puzzle, nor any of the other nice HTML, it might allow me to finish my game without making users jump through hoops for a little link. I need at least links to perform some multi-format acrobatics.

If I could give everyone the beautiful QTads experience, via the browser, I would do it in a heartbeat.

I’ve created a gist on GitHub to show how this abomination works.

5 Likes

Zarf’s original GlkOte has a detect_external_links option. I didn’t add it to AsyncGlk cause it didn’t seem like there was much desire for it (it’s not enabled by default in Quixe, and very few people have ever talked about turning it on.) If someone wanted to write an implementation for AsyncGlk then it will get added to Parchment. Maybe I’ll even enable it by default.

6 Likes

Yeah, I was going to bring up detect_external_links.

It’s a bit janky – the URL-detecting regex is a cobbled-together mess. I hate turning on janky options by default. If the regex goes wrong, that’s a game bug (from the player’s point of view) which the author had no way to see coming. (What if the game has fictional, in-game URLs that aren’t meant to be loaded in a real browser? Or what if the regex just gets the URL span wrong.)

However, I use detect_external_links on my own web site – for games where I put in URLs explicitly for external use and I know they all work with the feature.

(I also use “match” rather than “search”, because I know what the difference is, but it’s hard to explain as a documented feature.)

I’m not sure what the best plan is here.

4 Likes

I assume the main regex complication is excluding final punctuation? That feels like almost an impossible task though… for example a closing parentheses could be part of the URL (fairly common on Wikipedia for example) or not part of it. Excluding .,;:!? is probably the most that’s reasonable. Oh, I see that your regex tries to match balanced parentheses. Clever, but convoluted. I wonder if a little algorithm might be better than a single regex? That’s often the case…

5 Likes