Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tools/build_pygments_data: Map pygments language aliases to lexer name.
Sumanth V Rao4a2791e2a385
diff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.jsindex 61ab52b89fc..96556ab7ce8 100644--- a/frontend_tests/node_tests/typeahead_helper.js+++ b/frontend_tests/node_tests/typeahead_helper.js@@ -99,7 +99,14 @@ run_test("sort_streams", () => {run_test("sort_languages", () => {Object.assign(pygments_data, {- langs: {python: 40, javscript: 50, php: 38, pascal: 29, perl: 22, css: 0},+ langs: {+ python: {priority: 40},+ javscript: {priority: 50},+ php: {priority: 38},+ pascal: {priority: 29},+ perl: {priority: 22},+ css: {priority: 0},+ },});let test_langs = ["pascal", "perl", "php", "python", "javascript"];@@ -109,7 +116,7 @@ run_test("sort_languages", () => {assert.deepEqual(test_langs, ["python", "php", "pascal", "perl", "javascript"]);// Test if popularity between two languages are the same- pygments_data.langs.php = 40;+ pygments_data.langs.php = {priority: 40};test_langs = ["pascal", "perl", "php", "python", "javascript"];test_langs = th.sort_languages(test_langs, "p");diff --git a/static/js/typeahead_helper.js b/static/js/typeahead_helper.jsindex 1520323747a..b1ba7f8758d 100644--- a/static/js/typeahead_helper.js+++ b/static/js/typeahead_helper.js@@ -268,7 +268,7 @@ exports.sort_people_for_relevance = function (objs, current_stream_name, current};exports.compare_by_popularity = function (lang_a, lang_b) {- const diff = pygments_data.langs[lang_b] - pygments_data.langs[lang_a];+ const diff = pygments_data.langs[lang_b].priority - pygments_data.langs[lang_a].priority;if (diff !== 0) {return diff;}diff --git a/tools/setup/build_pygments_data b/tools/setup/build_pygments_dataindex 8b55ea399c2..86b9fcdab4c 100755--- a/tools/setup/build_pygments_data+++ b/tools/setup/build_pygments_data@@ -2,7 +2,7 @@import jsonimport os-from pygments.lexers import get_all_lexers+from pygments.lexers import get_all_lexers, get_lexer_by_nameZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../')DATA_PATH = os.path.join(ZULIP_PATH, 'tools', 'setup', 'lang.json')@@ -14,8 +14,10 @@ with open(DATA_PATH) as f:lexers = get_all_lexers()for lexer in lexers:for name in lexer[1]:- if name not in langs:- langs[name] = 0+ 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)diff --git a/version.py b/version.pyindex 301a6d96f57..9a1f7cfeb1d 100644--- a/version.py+++ b/version.py@@ -44,4 +44,4 @@ API_FEATURE_LEVEL = 32# historical commits sharing the same major version, in which case a# minor version bump suffices.-PROVISION_VERSION = '106.1'+PROVISION_VERSION = '107.1'