From 3ceaf266dacf825406ebb8011c52cbc352d5c53f Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Fri, 22 Feb 2019 14:39:06 +0700 Subject: [PATCH] support French --- lib/auto_linker/parser.ex | 2 +- test/auto_linker_test.exs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/auto_linker/parser.ex b/lib/auto_linker/parser.ex index 435ba83..c37f56c 100644 --- a/lib/auto_linker/parser.ex +++ b/lib/auto_linker/parser.ex @@ -44,7 +44,7 @@ defmodule AutoLinker.Parser do # https://www.w3.org/TR/html5/forms.html#valid-e-mail-address @match_email ~r/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/u - @match_hashtag ~r/^(?\#[[:word:]_]*[[:alpha:]_·][[:word:]_]*)/u + @match_hashtag ~r/^(?\#[[:word:]_]*[[:alpha:]_·][[:word:]_·]*)/u @prefix_extra [ "magnet:?", diff --git a/test/auto_linker_test.exs b/test/auto_linker_test.exs index 49a592b..fcbc47e 100644 --- a/test/auto_linker_test.exs +++ b/test/auto_linker_test.exs @@ -164,6 +164,21 @@ defmodule AutoLinkerTest do ) == expected end + test "support French" do + text = "#administrateur·rice·s #ingénieur·e·s" + + expected = + "#administrateur·rice·s #ingénieur·e·s" + + 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 = "google.com#test #test google.com/#test #tag"