powercord-community / suggestions

Repo where you can find and share plugin suggestions for Powercord
27 stars 4 forks source link

Markdown Links #280

Open YTG1234 opened 3 years ago

YTG1234 commented 3 years ago

Description

A plugin that makes Discord support displaying markdown links in the format of [text](address). So the text [Powercord](https://powercord.dev/) inside a message would look like Powercord.

More info

The text should be in the same colour as normal Discord links and have the exact same behaviour (ideally also compatible with plugins that modify how links work).


Snapperito commented 3 years ago

just note, this plugin would be very odd for any users who don't use the plugin. seeing as the md links would have to be client side.

YTG1234 commented 3 years ago

just note, this plugin would be very odd for any users who don't use the plugin. seeing as the md links would have to be client side.

Yeah I thought about that and decided to suggest it anyway.

Chromus-dev commented 3 years ago

just note, this plugin would be very odd for any users who don't use the plugin. seeing as the md links would have to be client side.

You could make it so it would just send the link for users who don't have the plugin.

oxbar commented 3 years ago

.

MulverineX commented 3 years ago

@Chromus-dev ooh maybe that would be possible with Zero Width Characters, c0dine has a plugin in the works for converting a whole message into zwc, could probably copy some code from that. (either once they release it or maybe you can get them to send the relevant code)

pwall2222 commented 3 years ago

In this last comment, i made a good snippet to convert from normal characters to 0 Width characters and i ought it may be usseful if someone picks it up here. It has a ratio of data to encoded data of 300% it can be bettered by ussing 11 invisible characters, that would lower it down to 200%.

const code = {
    encode: {
        /* Zero-Width Space U+200B */
        "0": "​",
        /* Zero-Width Non-Joiner U+200C */
        "1": "‌",
        /* Zero Width Joiner U+200D */
        "2": "‍",
        /* Invisible Separator U+2063 */
        "3": "⁣",
        /* Invisible Plus U+2064 */
        "4": "⁤"
    },
    decode: {
        "​": "0",
        "‌": "1",
        "‍": "2",
        "⁣": "3",
        "⁤": "4"
    },
    /* Invisible Times U+2062 */
    joiner: "⁢",
    base: 5,
    padding: 3
};
function encode(string) {
    let chararr = string.split("");
    let result = [];
    chararr.forEach(char => {
        let charcode = char.charCodeAt(0);
        if (charcode < 20 || charcode > 126) {
            throw new Error("Not accepted charcter, accepted character set U+0020 - U+007E");
        }
        charcode = charcode - 20;
        let bin = charcode.toString(code.base).padStart(code.padding, "0");
        bin = bin.replace(/./g, (key) => { return code.encode[key]; });
        result.push(bin);
    });
    return result.join(code.joiner);
}
function decode(string) {
    const arr = string.split(code.joiner);
    let result = [];
    arr.forEach(string => {
        let bin = string.replace(/./g, (key) => { return code.decode[key]; });
        let charcode = parseInt(bin, code.base) + 20;
        result.push(String.fromCharCode(charcode));
    });
    return result.join("");
}
cyyynthia commented 3 years ago

Discord intentionally made links behave this way. The only way to send such links is either to use embeds, or to send it using a webhook (since webhooks are allowed to use this markdown syntax, and it will render). I don't see any point in parsing links this way, especially since as mentioned it'll just look odd for users not using the plugin

MulverineX commented 3 years ago

On the contrary, it wouldn't look odd at all if ZWC was used, outside of it intrinsically being the full link to a vanilla client, but I would think that's common sense and not a real problem. Discord making it behave this way is irrelevant since this is a client-side choice you're making, that occurs for others who also make that choice. Additionally, there can be a hotkey or something that can reveal the full link inline, eg. with alt.