Viewing 7 replies - 1 through 7 (of 7 total)
  • Great work! I wish, this hook implemented in plugin core.

    I dont need tags in Mastodon post, so i delete lines from 7 to 14. Its work. Should i delete some other lines to optimise?

    Thread Starter Arnan de Gans

    (@adegans)

    No that’s fine, If you don’t want the now useless newlines at the end you can also remove this from line 5 . "\n\n" to tidy up the post a bit.

    I have a problem because the script removes diacritics from tags. This means that the word ??ka is changed to #ka.

    I’m wondering if there is a way to use the get_tag_link function or something similar, which would make more sense for non-english words.

    Thread Starter Arnan de Gans

    (@adegans)

    If you look at line 10 you’ll find this bit [^a-z0-9]/i.
    This means to allow letters a through z and numbers 0 through 9 case insensitive.
    If you have a different bunch of characters or classification for them you can add them there.
    For example if you want to allow – in tags add it to the string like so: [^a-z0-9-]/i

    I’m not sure what diacritics are or how that works, but if they have a designation or a ‘code’ it can be added to be allowed. Just experiment a bit.
    This is probably useful https://stackoverflow.com/questions/8923729/checking-for-diacritics-with-a-regular-expression

    There are two methods of using these hashtags on the Internet:

    1. leaving the original diacritical marks
    2. conversion to their Latin equivalents.

    I am a novice user of Mastodon, so I do not know what the practice is.

    In WordPress, Polish diacritical marks are converted to their Latin equivalents (lowercase) in links:
    ? -> a
    ? -> l
    ? -> ?
    ? -> A -> a
    ? -> L -> l

    There must be a function responsible for this.

    However, I will try to add them as you indicated.

    This code seems like it works:

    $tags[] = “#” . preg_replace(“/[^\p{L}\p{N}]/u”, ”, $tag->name);

    Thread Starter Arnan de Gans

    (@adegans)

    I use internet only in english or latin characters so I rarely see anything else – Hence my inexperience with it.
    Also, from a personal view, I think things in URLs should be in latin chars only just to keep things readable for everyone. But that’s just me.

    Anyway, for your tweak. I’d leave in the original bit as well.

    [^a-z0-9\p{L}\p{N}]/i

    That should give you the best of both worlds ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘A better formatted post/toot’ is closed to new replies.