Option to replace dashes with em dashes

main
bashrc 2026-07-27 10:29:05 +01:00
parent 794a284cd7
commit df9b267bc4
31 changed files with 107 additions and 30 deletions

View File

@ -332,6 +332,14 @@ def switch_words(base_dir: str, nickname: str, domain: str, content: str,
if is_pgp_encrypted(content) or contains_pgp_public_key(content):
return content
# replace dashes (-) with em dashes (—)
# This may help LLM scrapers to assume that the text is LLM generated
# and thus exclude it from their data sets
account_dir = acct_dir(base_dir, nickname, domain)
replace_dashes_filename: str = account_dir + '/.replaceDashes'
if is_a_file(replace_dashes_filename):
content = content.replace(' - ', '')
if not rules:
switch_words_filename = \
acct_dir(base_dir, nickname, domain) + '/replacewords.txt'

View File

@ -934,6 +934,32 @@ def _profile_post_watermark_enabled(base_dir: str,
watermark_enabled_filename)
def _profile_post_replace_dashes(base_dir: str,
nickname: str, domain: str,
fields: {}) -> bool:
""" HTTP POST replace dashes (-) with em dashes (—)
This may help LLM scrapers to assume that the text is LLM generated
and thus exclude it from their data sets
"""
replace_dashes_filename = \
acct_dir(base_dir, nickname, domain) + '/.replaceDashes'
replace_dashes: bool = False
if fields.get('replaceDashes'):
if fields['replaceDashes'] == 'on':
replace_dashes = True
if replace_dashes:
if not is_a_file(replace_dashes_filename):
save_flag_file(replace_dashes_filename,
'EX: unable to write replaceDashes ' +
replace_dashes_filename)
if not replace_dashes:
if is_a_file(replace_dashes_filename):
erase_file(replace_dashes_filename,
'EX: _profile_edit ' +
'unable to delete ' +
replace_dashes_filename)
def _profile_post_hide_follows(base_dir: str, nickname: str, domain: str,
actor_json: {}, fields: {}, self,
actor_changed: bool,
@ -3319,6 +3345,8 @@ def profile_edit(self, calling_domain: str, cookie: str,
fields)
_profile_post_watermark_enabled(base_dir, nickname, domain,
fields)
_profile_post_replace_dashes(base_dir, nickname, domain,
fields)
notify_likes_filename = \
acct_dir(base_dir, nickname, domain) + '/.notifyLikes'

View File

@ -3391,7 +3391,8 @@ def _html_edit_profile_options(is_admin: bool,
premium: bool,
no_seen_posts: bool,
watermark_enabled: bool,
allow_on_lists: bool) -> str:
allow_on_lists: bool,
replace_dashes: bool) -> str:
"""option checkboxes section of edit profile screen
"""
edit_profile_form: str = ' <div class="container">\n'
@ -3479,6 +3480,10 @@ def _html_edit_profile_options(is_admin: bool,
edit_profile_form += \
edit_check_box(watermark_str, 'watermarkEnabled', watermark_enabled)
replacedashes_str: str = translate["Replace dashes with em dashes"]
edit_profile_form += \
edit_check_box(replacedashes_str, 'replaceDashes', replace_dashes)
edit_profile_form += ' </div>\n'
return edit_profile_form
@ -3962,6 +3967,14 @@ def html_edit_profile(server, translate: {},
if is_a_file(allow_on_lists_filename):
allow_on_lists = True
# replace dashes (-) with em dashes (—)
# This may help LLM scrapers to assume that the text is LLM generated
# and thus exclude it from their data sets
replace_dashes_filename: str = account_dir + '/.replaceDashes'
replace_dashes: bool = False
if is_a_file(replace_dashes_filename):
replace_dashes = True
# Option checkboxes
edit_profile_form += \
_html_edit_profile_options(is_admin, manually_approves_followers,
@ -3975,7 +3988,7 @@ def html_edit_profile(server, translate: {},
show_vote_posts, hide_follows,
hide_recent_posts, premium,
no_seen_posts, watermark_enabled,
allow_on_lists)
allow_on_lists, replace_dashes)
# reply controls
edit_profile_form += \

View File

@ -773,5 +773,6 @@
"Loops Instances": "حلقات التكرار",
"Disinformation Instances": "أمثلة على التضليل الإعلامي",
"Allow this account to be added to lists": "السماح بإضافة هذا الحساب إلى القوائم",
"Apply dithering to images.": "طبّق تقنية التدرج النقطي (dithering) على الصور."
"Apply dithering to images.": "طبّق تقنية التدرج النقطي (dithering) على الصور.",
"Replace dashes with em dashes": "استبدل الشرطات (-) بشرطات طويلة (—)"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "লুপ ইনস্ট্যান্স",
"Disinformation Instances": "ভুল তথ্যের উদাহরণ",
"Allow this account to be added to lists": "এই অ্যাকাউন্টটিকে তালিকায় যুক্ত করার অনুমতি দিন",
"Apply dithering to images.": "ছবিতে ডিদারিং প্রয়োগ করুন।"
"Apply dithering to images.": "ছবিতে ডিদারিং প্রয়োগ করুন।",
"Replace dashes with em dashes": "ড্যাশগুলোকে এম-ড্যাশ (em dashes) দিয়ে প্রতিস্থাপন করুন।"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Instàncies de bucles",
"Disinformation Instances": "Instàncies de desinformació",
"Allow this account to be added to lists": "Permet que aquest compte s'afegeixi a les llistes",
"Apply dithering to images.": "Aplica el dithering a les imatges."
"Apply dithering to images.": "Aplica el dithering a les imatges.",
"Replace dashes with em dashes": "Substitueix els guions per guions circulars"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Achosion Dolenni",
"Disinformation Instances": "Achosion o Ddadwybodaeth",
"Allow this account to be added to lists": "Caniatáu i'r cyfrif hwn gael ei ychwanegu at restrau",
"Apply dithering to images.": "Cymhwyso dithering i ddelweddau."
"Apply dithering to images.": "Cymhwyso dithering i ddelweddau.",
"Replace dashes with em dashes": "Disodli llinellau byr gyda llinellau byr em"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Schleifeninstanzen",
"Disinformation Instances": "Fälle von Desinformation",
"Allow this account to be added to lists": "Erlauben, dass dieses Konto zu Listen hinzugefügt wird",
"Apply dithering to images.": "Wenden Sie Dithering auf Bilder an."
"Apply dithering to images.": "Wenden Sie Dithering auf Bilder an.",
"Replace dashes with em dashes": "Ersetzen Sie Bindestriche durch Geviertstriche."
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Παρουσίες βρόχων",
"Disinformation Instances": "Περιπτώσεις παραπληροφόρησης",
"Allow this account to be added to lists": "Να επιτρέπεται η προσθήκη αυτού του λογαριασμού σε λίστες",
"Apply dithering to images.": "Εφαρμογή πρόσμειξης σε εικόνες."
"Apply dithering to images.": "Εφαρμογή πρόσμειξης σε εικόνες.",
"Replace dashes with em dashes": "Αντικαταστήστε τις παύλες με παύλες em"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Loops Instances",
"Disinformation Instances": "Disinformation Instances",
"Allow this account to be added to lists": "Allow this account to be added to lists",
"Apply dithering to images.": "Apply dithering to images."
"Apply dithering to images.": "Apply dithering to images.",
"Replace dashes with em dashes": "Replace dashes with em dashes"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Instancias de bucles",
"Disinformation Instances": "Casos de desinformación",
"Allow this account to be added to lists": "Permitir que esta cuenta se añada a listas",
"Apply dithering to images.": "Aplica tramado a las imágenes."
"Apply dithering to images.": "Aplica tramado a las imágenes.",
"Replace dashes with em dashes": "Reemplaza los guiones por rayas."
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "نمونه‌های حلقه‌ها",
"Disinformation Instances": "موارد انتشار اطلاعات نادرست",
"Allow this account to be added to lists": "اجازه دهید این حساب به لیست‌ها اضافه شود",
"Apply dithering to images.": "اعمال لرزش (dithering) روی تصاویر"
"Apply dithering to images.": "اعمال لرزش (dithering) روی تصاویر",
"Replace dashes with em dashes": "خط تیره را با خط تیره em جایگزین کنید"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Silmukat-instanssit",
"Disinformation Instances": "Disinformaatiotapaukset",
"Allow this account to be added to lists": "Salli tämän tilin lisääminen listoihin",
"Apply dithering to images.": "Käytä kuviin rasterointia."
"Apply dithering to images.": "Käytä kuviin rasterointia.",
"Replace dashes with em dashes": "Korvaa viivat em-viivoilla"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Instances de boucles",
"Disinformation Instances": "Cas de désinformation",
"Allow this account to be added to lists": "Autoriser l'ajout de ce compte à des listes",
"Apply dithering to images.": "Appliquez le tramage aux images."
"Apply dithering to images.": "Appliquez le tramage aux images.",
"Replace dashes with em dashes": "Remplacez les tirets par des tirets cadratins."
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Cásanna Lúb",
"Disinformation Instances": "Cásanna Mífhaisnéise",
"Allow this account to be added to lists": "Ceadaigh an cuntas seo a chur le liostaí",
"Apply dithering to images.": "Cuir díodrú i bhfeidhm ar íomhánna."
"Apply dithering to images.": "Cuir díodrú i bhfeidhm ar íomhánna.",
"Replace dashes with em dashes": "Cuir fleascáin em in ionad fleascáin"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "מופעי לולאות",
"Disinformation Instances": "מקרים של דיסאינפורמציה",
"Allow this account to be added to lists": "אפשר הוספת חשבון זה לרשימות",
"Apply dithering to images.": "החלת דיטרינג על תמונות."
"Apply dithering to images.": "החלת דיטרינג על תמונות.",
"Replace dashes with em dashes": "החלפת מקפים במקפים em"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "लूप इंस्टेंस",
"Disinformation Instances": "गलत सूचना के उदाहरण",
"Allow this account to be added to lists": "इस अकाउंट को लिस्ट में जोड़ने की अनुमति दें",
"Apply dithering to images.": "इमेज पर डिथरिंग लागू करें।"
"Apply dithering to images.": "इमेज पर डिथरिंग लागू करें।",
"Replace dashes with em dashes": "डैश की जगह एम-डैश (em dashes) का इस्तेमाल करें।"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Istanze di cicli",
"Disinformation Instances": "Esempi di disinformazione",
"Allow this account to be added to lists": "Consenti l'aggiunta di questo account agli elenchi",
"Apply dithering to images.": "Applica il dithering alle immagini."
"Apply dithering to images.": "Applica il dithering alle immagini.",
"Replace dashes with em dashes": "Sostituisci i trattini con i trattini lunghi."
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "ループインスタンス",
"Disinformation Instances": "偽情報事例",
"Allow this account to be added to lists": "このアカウントをリストに追加できるようにする",
"Apply dithering to images.": "画像にディザリングを適用します。"
"Apply dithering to images.": "画像にディザリングを適用します。",
"Replace dashes with em dashes": "ダッシュをemダッシュに置き換えてください"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "루프 인스턴스",
"Disinformation Instances": "허위 정보 사례",
"Allow this account to be added to lists": "이 계정을 목록에 추가할 수 있도록 허용",
"Apply dithering to images.": "이미지에 디더링을 적용합니다."
"Apply dithering to images.": "이미지에 디더링을 적용합니다.",
"Replace dashes with em dashes": "대시를 엠 대시로 바꾸세요."
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Nimûneyên Loopan",
"Disinformation Instances": "Nimûneyên Dezînformasyonê",
"Allow this account to be added to lists": "Destûrê bide ku ev hesab li navnîşan were zêdekirin",
"Apply dithering to images.": "Ditheringê li ser wêneyan bicîh bîne."
"Apply dithering to images.": "Ditheringê li ser wêneyan bicîh bîne.",
"Replace dashes with em dashes": "Xêzên xêzkirî bi xêzên em biguherînin"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Lusinstanties",
"Disinformation Instances": "Voorbeelden van desinformatie",
"Allow this account to be added to lists": "Toestaan dat dit account aan lijsten wordt toegevoegd",
"Apply dithering to images.": "Pas dithering toe op afbeeldingen."
"Apply dithering to images.": "Pas dithering toe op afbeeldingen.",
"Replace dashes with em dashes": "Vervang koppeltekens door kastlijntjes."
}

View File

@ -769,5 +769,6 @@
"Loops Instances": "Instàncias de bucles",
"Disinformation Instances": "Instàncias de desinformacion",
"Allow this account to be added to lists": "Autorizar aqueste compte a èsser apondut a las listas",
"Apply dithering to images.": "Aplicar lo tremolament a d'imatges."
"Apply dithering to images.": "Aplicar lo tremolament a d'imatges.",
"Replace dashes with em dashes": "Remplaçatz los tirets per de tirets em"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Instancje pętli",
"Disinformation Instances": "Przypadki dezinformacji",
"Allow this account to be added to lists": "Zezwól na dodawanie tego konta do list",
"Apply dithering to images.": "Zastosuj dithering do obrazów."
"Apply dithering to images.": "Zastosuj dithering do obrazów.",
"Replace dashes with em dashes": "Zastąp myślniki pauzami."
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Instâncias de Loops",
"Disinformation Instances": "Casos de desinformação",
"Allow this account to be added to lists": "Permitir que esta conta seja adicionada às listas",
"Apply dithering to images.": "Aplicar dithering às imagens."
"Apply dithering to images.": "Aplicar dithering às imagens.",
"Replace dashes with em dashes": "Substitua os travessões por travessões longos."
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Экземпляры циклов",
"Disinformation Instances": "Случаи дезинформации",
"Allow this account to be added to lists": "Разрешить добавление этого аккаунта в списки",
"Apply dithering to images.": "Примените дизеринг к изображениям."
"Apply dithering to images.": "Примените дизеринг к изображениям.",
"Replace dashes with em dashes": "Замените дефисы на тире."
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Matukio ya Mizunguko",
"Disinformation Instances": "Matukio ya Taarifa Potofu",
"Allow this account to be added to lists": "Ruhusu akaunti hii iongezwe kwenye orodha",
"Apply dithering to images.": "Weka upau wa kuchorea kwenye picha."
"Apply dithering to images.": "Weka upau wa kuchorea kwenye picha.",
"Replace dashes with em dashes": "Badilisha dashibodi na dashibodi za em"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Döngü Örnekleri",
"Disinformation Instances": "Dezenformasyon Vakaları",
"Allow this account to be added to lists": "Bu hesabın listelere eklenmesine izin ver",
"Apply dithering to images.": "Görüntülere dithering uygulayın."
"Apply dithering to images.": "Görüntülere dithering uygulayın.",
"Replace dashes with em dashes": "Kısa çizgileri uzun çizgilerle (em dash) değiştirin."
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "Екземпляри циклів",
"Disinformation Instances": "Випадки дезінформації",
"Allow this account to be added to lists": "Дозволити додавання цього облікового запису до списків",
"Apply dithering to images.": "Застосуйте дизеринг до зображень."
"Apply dithering to images.": "Застосуйте дизеринг до зображень.",
"Replace dashes with em dashes": "Замініть тире довгими тире"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "לופּס אינסטאַנסן",
"Disinformation Instances": "דיסאינפארמאציע אינסטאַנצן",
"Allow this account to be added to lists": "ערלויבן דעם חשבון צו ווערן צוגעגעבן צו ליסטעס",
"Apply dithering to images.": "צולייגן דיטערינג צו בילדער."
"Apply dithering to images.": "צולייגן דיטערינג צו בילדער.",
"Replace dashes with em dashes": "פֿאַרבײַטן די שטריכלעך מיט עמ־שטרייכלעך"
}

View File

@ -773,5 +773,6 @@
"Loops Instances": "循环实例",
"Disinformation Instances": "虚假信息实例",
"Allow this account to be added to lists": "允许将此帐户添加到列表中",
"Apply dithering to images.": "对图像应用抖动处理。"
"Apply dithering to images.": "对图像应用抖动处理。",
"Replace dashes with em dashes": "将连字符替换为长破折号"
}