mirror of
https://codeberg.org/catask-org/catask.git
synced 2025-04-19 13:23:41 -05:00
fix rendering of emojis with camelCase names
This commit is contained in:
parent
ad4f34c7db
commit
283f2e5784
1 changed files with 9 additions and 2 deletions
|
@ -277,11 +277,18 @@ EMOJI_BASE_PATH = Path.cwd() / 'static' / 'emojis'
|
|||
|
||||
emoji_cache = {}
|
||||
|
||||
def to_snake_case(name):
|
||||
name = re.sub(r'(.)([A-Z][a-z]+)', r'\1_\2', name)
|
||||
return re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', name).lower()
|
||||
|
||||
def find_emoji_path(emoji_name):
|
||||
if '_' in emoji_name:
|
||||
head, sep, tail = emoji_name.partition('_')
|
||||
else:
|
||||
head = to_snake_case(emoji_name).split('_')[0]
|
||||
if any(Path(EMOJI_BASE_PATH).glob(f'{head}.json')):
|
||||
for json_file in Path(EMOJI_BASE_PATH).glob('*.json'):
|
||||
print("\n[CatAsk/functions/find_emoji_path] Using JSON meta file\n")
|
||||
app.logger.debug("\n[CatAsk/functions/find_emoji_path] Using JSON meta file\n")
|
||||
pack_data = loadJSON(json_file)
|
||||
emojis = pack_data.get('emojis', [])
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue