mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
pygments_data: Replace JS module with JSON module.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Tim Abbott
parent
e257253e64
commit
d7d8632525
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user