logo

auto_linker

AutoLinker-shim, based on https://git.pleroma.social/pleroma/auto_linker
commit: 55debce3de6883485f77e88425dda710f5484b66
parent: 2079f895139cc6bd53b7c191935f7a4f95d6b281
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri,  5 Apr 2019 01:33:08 +0200

Merge remote-tracking branch 'upstream/master' into lanodan/master

Diffstat:

Mlib/auto_linker/parser.ex2+-
Mtest/auto_linker_test.exs15+++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/auto_linker/parser.ex b/lib/auto_linker/parser.ex @@ -27,7 +27,7 @@ defmodule AutoLinker.Parser do # https://www.w3.org/TR/html5/forms.html#valid-e-mail-address @valid_email ~r/.*@.*/u - @match_hashtag ~r/^(?<tag>\#[[:word:]_]*[[:alpha:]_·][[:word:]_·]*)/u + @match_hashtag ~r/^(?<tag>\#[[:word:]_]*[[:alpha:]_·][[:word:]_·\p{M}]*)/u @default_opts ~w(url)a diff --git a/test/auto_linker_test.exs b/test/auto_linker_test.exs @@ -187,6 +187,21 @@ defmodule AutoLinkerTest do ) == expected end + test "support Telugu" do + text = "#చక్రం #కకకకక్ #కకకకాక #కకకక్రకకకక" + + expected = + "<a href=\"/t/చక్రం\">#చక్రం</a> <a href=\"/t/కకకకక్\">#కకకకక్</a> <a href=\"/t/కకకకాక\">#కకకకాక</a> <a href=\"/t/కకకక్రకకకక\">#కకకక్రకకకక</a>" + + assert AutoLinker.link(text, + hashtag: true, + hashtag_prefix: "/t/", + class: false, + rel: false, + new_window: false + ) == expected + end + test "do not turn urls with hashes into hashtags" do text = "#test http://google.com/#test #tag"