You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a tag has hyphens in it the words separated by hyphens should be capitalized. Patch:
From 6186667dd20aa4f01e608d809894d4d4d42429dd Mon Sep 17 00:00:00 2001
From: Jonathan Kamens <[email protected]>
Date: Tue, 13 Jun 2023 11:13:20 -0400
Subject: [PATCH] Treat do CamelCase properly for words tags with hyphens in
them
When we encounter a tag with hyphens in it, convert the hyphens to
spaces before doing the CamelCase conversion on the tag, so that words
separated by hyphens are properly capitalized.
---
trunk/mastodon_autopost.php | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/trunk/mastodon_autopost.php b/trunk/mastodon_autopost.php
index be85606..02f93a5 100644
--- a/trunk/mastodon_autopost.php
+++ b/trunk/mastodon_autopost.php
@@ -552,6 +552,12 @@ class autopostToMastodon
private function fixHashTag($tag)
{
$tag = html_entity_decode($tag, ENT_COMPAT, 'UTF-8');
+ // Treat hyphens as spaces for purposes of CamelCase capitalization.
+ // \u{2013} is en dash. \u{2014} is em dash.
+ // I tried putting the three characters inside [] instead of using |
+ // and it gave weird results, presumably because Unicode characters
+ // inside [] behaves weirdly, so that's why I'm using | here.
+ $tag = preg_replace("/-|\u{2013}|\u{2014}/", ' ', $tag);
if (preg_match('/\s/', $tag)) {
$tag = ucwords($tag);
}
--
2.40.1
The text was updated successfully, but these errors were encountered:
When a tag has hyphens in it the words separated by hyphens should be capitalized. Patch:
The text was updated successfully, but these errors were encountered: