Hyperlink Suppression Module

As far as I know, this should be library-agnostic, and was inspired by @SomeOne2.

A neat feature of HTML TADS is clickable text, which some might find to be a crucial convenience, depending on the kind of game they’re making.

However, as a puzzle author, the presence of clickable text can be a bit of a built-in spoiler, and if parts of library use it (even if you don’t), then it creates an annoying inconsistency in your game.

For this reason, I have made this quick drop-in module called the Hyperlink Suppressor.

hyperlinkSuppressor.t
function hyperlinkSuppressorTest(href) {
    local lowerTest = href.toLower().trim();
    local extensionPattern = R'(?:%w|%d)%.%w{2,4}(?:%/|$|%.)';
    if (lowerTest.startsWith('http')) {
        return true;
    }
    else if (lowerTest.startsWith('www')) {
        return true;
    }
    else if (lowerTest.find(extensionPattern) != nil) {
        return true;
    }
    return nil;
}

replace function aHref(href, txt?, title?, flags = 0) {
    if (hyperlinkSuppressorTest(href)) {
        if (txt != nil) {
            say(txt + ' (' + href + ')');
        }
        else {
            say(href);
        }
    }
    else if (txt != nil) {
        say(txt);
    }
}

replace function aHrefAlt(href, linkedText, altText, title?) {
    if (linkedText != nil && hyperlinkSuppressorTest(href)) {
        say(linkedText + ' (' + href + ')');
    }
    else if (altText != nil) {
        say(altText);
    }
    else {
        say(href);
    }
}

hyperlinkSuppressor.t (954 Bytes)

Simply drop this module into your project folder, and include it with:

#include "hyperlinkSuppressor.t"

(or include it with your makefile)

This include line should come after the line that includes Adv3/Adv3Lite, as it overrides two functions from those libraries.

4 Likes