Files
zulip/tools/setup/build_pygments_data
Anders Kaseorg d7d8632525 pygments_data: Replace JS module with JSON module.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-02-12 10:09:12 -08:00

22 lines
571 B
Python
Executable File

#!/usr/bin/env python3
from pygments.lexers import get_all_lexers
import json
import os
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]:
if name not in langs:
langs[name] = 0
with open(OUT_PATH, 'w') as f:
json.dump({"langs": langs}, f)