pygments_data: Replace JS module with JSON module.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-02-05 22:44:36 -08:00
committed by Tim Abbott
parent e257253e64
commit d7d8632525
11 changed files with 14 additions and 29 deletions

View File

@@ -6,7 +6,7 @@ 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')
JS_PATH = os.path.join(ZULIP_PATH, 'static', 'generated', 'pygments_data.js')
OUT_PATH = os.path.join(ZULIP_PATH, 'static', 'generated', 'pygments_data.json')
with open(DATA_PATH) as f:
langs = json.load(f)
@@ -17,18 +17,5 @@ for lexer in lexers:
if name not in langs:
langs[name] = 0
template = '''var pygments_data = (function () {
var exports = {};
exports.langs = %s;
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = pygments_data;
}''' % (json.dumps(langs),)
with open(JS_PATH, 'w') as f:
f.write(template)
with open(OUT_PATH, 'w') as f:
json.dump({"langs": langs}, f)