mirror of
https://github.com/sorenpeter/timeline.git
synced 2025-12-15 19:07:01 +00:00
Hashtags now support special characters like accents
This commit is contained in:
parent
ce17f2042b
commit
ee7e6558b2
1 changed files with 5 additions and 3 deletions
|
|
@ -124,7 +124,8 @@ function getImagesFromTwt(string $twtString) {
|
||||||
|
|
||||||
function getTagsFromTwt(string $twtString) {
|
function getTagsFromTwt(string $twtString) {
|
||||||
//$pattern = '/(?<!\()\B#\w+(?!\))/iu';
|
//$pattern = '/(?<!\()\B#\w+(?!\))/iu';
|
||||||
$pattern = '/(?<=\B)#(\w+)/';
|
//$pattern = '/(?<=\B)#(\w+)/';
|
||||||
|
$pattern = '/(?<=\B)#([\p{L}\p{N}_]+)/u';
|
||||||
//$pattern = '/(?<=\s)#(\w+)/';
|
//$pattern = '/(?<=\s)#(\w+)/';
|
||||||
//$pattern = '/\s#(\w+)/';
|
//$pattern = '/\s#(\w+)/';
|
||||||
//$pattern = "/\(#\w{7}\)/";
|
//$pattern = "/\(#\w{7}\)/";
|
||||||
|
|
@ -213,8 +214,9 @@ function replaceImagesFromTwt(string $twtString) {
|
||||||
|
|
||||||
function replaceTagsFromTwt(string $twtString) {
|
function replaceTagsFromTwt(string $twtString) {
|
||||||
//$pattern = '/#(\w+)?/';
|
//$pattern = '/#(\w+)?/';
|
||||||
$pattern = '/(?<=\s)#(\w+)/';
|
//$pattern = '/(?<=\s)#(\w+)/';
|
||||||
|
$pattern = '/(?<=\B)#([\p{L}\p{N}_]+)/u';
|
||||||
|
|
||||||
//$replacement = '<a href="#">#\1</a>'; // Dummy link
|
//$replacement = '<a href="#">#\1</a>'; // Dummy link
|
||||||
$replacement = '<a href="?search=$1" class="tag">#${1}</a>';
|
$replacement = '<a href="?search=$1" class="tag">#${1}</a>';
|
||||||
$result = preg_replace($pattern, $replacement, $twtString);
|
$result = preg_replace($pattern, $replacement, $twtString);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue