mirror of
https://github.com/zulip/zulip.git
synced 2026-06-21 21:32:29 +08:00
We need this information in the frontend to:
* Display the 'view in playground' option for locally echoed messages.
* When we add a UI settings for realm admins to configure their
playground choices, we'll need to use these canonicalized aliases
for displaying the option.
Hence, this tweaks the tool which generates pygments_data.json to contain
the data we need.
Bumping major PROVISION_VERSION since folks need to provision in both
directions.
Tests amended.
24 lines
666 B
Python
Executable File
24 lines
666 B
Python
Executable File
#!/usr/bin/env python3
|
|
import json
|
|
import os
|
|
|
|
from pygments.lexers import get_all_lexers, get_lexer_by_name
|
|
|
|
ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../')
|
|
DATA_PATH = os.path.join(ZULIP_PATH, 'tools', 'setup', 'lang.json')
|
|
OUT_PATH = os.path.join(ZULIP_PATH, 'static', 'generated', 'pygments_data.json')
|
|
|
|
with open(DATA_PATH) as f:
|
|
langs = json.load(f)
|
|
|
|
lexers = get_all_lexers()
|
|
for lexer in lexers:
|
|
for name in lexer[1]:
|
|
langs[name] = {
|
|
'priority': langs.get(name, 0),
|
|
'pretty_name': get_lexer_by_name(name).name
|
|
}
|
|
|
|
with open(OUT_PATH, 'w') as f:
|
|
json.dump({"langs": langs}, f)
|