js: Avoid _.get.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-01-24 00:27:28 -08:00 committed by Tim Abbott
parent cc40352541
commit 392676d4da
2 changed files with 2 additions and 2 deletions

View File

@ -260,7 +260,7 @@ function retain_unique_language_aliases(matches) {
for (const lang of matches) {
// The matched list is already sorted based on popularity and has exact matches
// at the top, so we don't need to worry about sorting again.
const canonical_name = _.get(pygments_data.langs, [lang, "pretty_name"], lang);
const canonical_name = pygments_data.langs[lang]?.pretty_name ?? lang;
if (!seen_aliases.has(canonical_name)) {
seen_aliases.add(canonical_name);
unique_aliases.push(lang);

View File

@ -46,7 +46,7 @@ export function wrap_code(code, lang) {
// the `/shared` folder. To handle such a case we check if pygments data is empty and fallback to
// using the default header if it is.
if (lang !== undefined && lang !== "" && Object.keys(pygments_data).length > 0) {
const code_language = _.get(pygments_data, [lang, "pretty_name"], lang);
const code_language = pygments_data[lang]?.pretty_name ?? lang;
header = `<div class="codehilite" data-code-language="${_.escape(
code_language,
)}"><pre><span></span><code>`;