diff --git a/.eslintrc.json b/.eslintrc.json index ba35114dd3..c11ba1d14e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -118,7 +118,6 @@ "pointer": false, "popovers": false, "presence": false, - "pygments_data": false, "reactions": false, "realm_icon": false, "realm_logo": false, diff --git a/docs/subsystems/dependencies.md b/docs/subsystems/dependencies.md index f8ea226c0d..350549224a 100644 --- a/docs/subsystems/dependencies.md +++ b/docs/subsystems/dependencies.md @@ -320,7 +320,7 @@ implementation of that tool. The list of languages supported by our markdown syntax highlighting comes from the [pygments][] package. `tools/setup/build_pygments_data` is -responsible for generating `static/generated/pygments_data.js` so that +responsible for generating `static/generated/pygments_data.json` so that our JavaScript markdown processor has access to the supported list. ### Authors data diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.js index 5db61eb03e..71b27d26dc 100644 --- a/frontend_tests/node_tests/composebox_typeahead.js +++ b/frontend_tests/node_tests/composebox_typeahead.js @@ -178,9 +178,7 @@ emoji.active_realm_emojis = new Map(); emoji.emojis_by_name = emojis_by_name; emoji.emojis = emoji_list; -set_global('pygments_data', {langs: - {python: 0, javscript: 1, html: 2, css: 3}, -}); +const pygments_data = zrequire("pygments_data", "generated/pygments_data.json"); const alice = { email: 'alice@zulip.com', diff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.js index 3b492ef75b..e2e2229233 100644 --- a/frontend_tests/node_tests/typeahead_helper.js +++ b/frontend_tests/node_tests/typeahead_helper.js @@ -14,7 +14,8 @@ zrequire('stream_data'); zrequire('narrow'); zrequire('hash_util'); zrequire('marked', 'third/marked/lib/marked'); -const actual_pygments_data = zrequire('actual_pygments_data', 'generated/pygments_data'); +const pygments_data = zrequire('pygments_data', 'generated/pygments_data.json'); +const actual_pygments_data = Object.assign({}, pygments_data); zrequire('settings_org'); const ct = zrequire('composebox_typeahead'); const th = zrequire('typeahead_helper'); @@ -96,7 +97,7 @@ run_test('sort_streams', () => { }); run_test('sort_languages', () => { - set_global('pygments_data', {langs: + Object.assign(pygments_data, {langs: {python: 40, javscript: 50, php: 38, pascal: 29, perl: 22, css: 0}, }); @@ -107,7 +108,7 @@ run_test('sort_languages', () => { assert.deepEqual(test_langs, ["python", "php", "pascal", "perl", "javascript"]); // Test if popularity between two languages are the same - global.pygments_data.langs.php = 40; + pygments_data.langs.php = 40; test_langs = ["pascal", "perl", "php", "python", "javascript"]; test_langs = th.sort_languages(test_langs, "p"); @@ -118,7 +119,7 @@ run_test('sort_languages', () => { // We may eventually want to use human-readable names like // "JavaScript" with several machine-readable aliases for what the // user typed, which might help provide a better user experience. - global.pygments_data = actual_pygments_data; + Object.assign(pygments_data, actual_pygments_data); test_langs = ["j", "java", "javascript", "js"]; // Sort acccording to priority only. diff --git a/static/.gitignore b/static/.gitignore index 10c5fe127b..8bbc4a59c0 100644 --- a/static/.gitignore +++ b/static/.gitignore @@ -8,7 +8,7 @@ # From emoji /generated/emoji # From passing pygments data to the frontend -/generated/pygments_data.js +/generated/pygments_data.json # From `tools/update-authors-json` /generated/github-contributors.json diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js index 3901e64e4b..d5e4fcbb40 100644 --- a/static/js/bundles/app.js +++ b/static/js/bundles/app.js @@ -17,7 +17,6 @@ import "handlebars/dist/cjs/handlebars.runtime.js"; import "flatpickr/dist/flatpickr.js"; import "flatpickr/dist/plugins/confirmDate/confirmDate.js"; import "sortablejs/Sortable.js"; -import "../../generated/pygments_data.js"; // Import App JS import "../translations.js"; diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js index 805b9ceb36..454159027b 100644 --- a/static/js/composebox_typeahead.js +++ b/static/js/composebox_typeahead.js @@ -1,3 +1,4 @@ +const pygments_data = require("../generated/pygments_data.json"); const typeahead = require("../shared/js/typeahead"); const autosize = require('autosize'); diff --git a/static/js/typeahead_helper.js b/static/js/typeahead_helper.js index c1abba262f..11e6825f7e 100644 --- a/static/js/typeahead_helper.js +++ b/static/js/typeahead_helper.js @@ -1,3 +1,4 @@ +const pygments_data = require("../generated/pygments_data.json"); const typeahead = require("../shared/js/typeahead"); const render_typeahead_list_item = require('../templates/typeahead_list_item.hbs'); const IntDict = require('./int_dict').IntDict; diff --git a/tools/setup/build_pygments_data b/tools/setup/build_pygments_data index c0f952291a..7c15888c35 100755 --- a/tools/setup/build_pygments_data +++ b/tools/setup/build_pygments_data @@ -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) diff --git a/tools/webpack.config.ts b/tools/webpack.config.ts index acf92d3d99..154675c018 100644 --- a/tools/webpack.config.ts +++ b/tools/webpack.config.ts @@ -221,7 +221,6 @@ export default (env?: string): webpack.Configuration[] => { { path: "clipboard/dist/clipboard.js", name: "ClipboardJS" }, { path: "xdate/src/xdate.js", name: "XDate" }, { path: "../static/third/marked/lib/marked.js" }, - { path: "../static/generated/pygments_data.js" }, { path: "../static/js/debug.js" }, { path: "../static/js/blueslip.js" }, { path: "../static/js/common.js" }, diff --git a/version.py b/version.py index 41d6b10af6..dcff2aaa43 100644 --- a/version.py +++ b/version.py @@ -26,4 +26,4 @@ LATEST_RELEASE_ANNOUNCEMENT = "https://blog.zulip.org/2019/12/13/zulip-2-1-relea # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = '71.0' +PROVISION_VERSION = '72.0'