9

Shouldn't Javascript highlighting support template literals by now? The whole thing looks like a big giant string from ` to `, or worse, consider everything as code. No respect for ${} at all.

Just look at this:

var str = `
    Hello ${obj.firstName + " " + obj.lastName}!
    <div class="${obj.adult? "adult": ""} human">
        <div>Age: ${obj.age}</div>
        <div>Occupation: ${obj.occ}</div>
        <div class="pictures">
        ${
            obj.pictures.map(function(pic) {
                return `<img class="picture" src="${pic.src}" alt="${pic.alt}">`;
            }).join("");
        }
        </div>
    </div>
`;

It's really hard to spot code inside the template literal, and this is a well indented example. There are far worse, believe me.

6
  • 1
    @cpburnz I don't think the duplicate link fits. This is a feature request. I'm not asking how does it work. I'm asking for them to add support of template literal. May 2, 2018 at 2:36
  • 6
    The title of the linked question doesn't fit, but the answer does. In particular, "Stack Exchange does not have its own syntax highlighting engine. It uses Google Code Prettify. Therefore, any bugs and feature requests regarding syntax highlighting cannot be handled by Stack Exchange and should be directed to the team behind Google Code Prettify." May 2, 2018 at 3:00
  • 1
    Direct link to Google Code Prettify issue: github.com/google/code-prettify/issues/492 Apr 8, 2019 at 10:40
  • 1
    @cpburnz I think an answer to that effect would make far more sense than the completely nonsensical duplicate closure here. Questions are only duplicates if all answers to the target question are also answers to the supposed duplicate and vice versa. That is blatantly not the case here and this closure is an abuse of the closure system.
    – user4639281
    Apr 8, 2019 at 15:21
  • @TinyGiant In general I agree. However, in the case of syntax highlighting SO uses Google Code Prettify. The only answer to this question is to ask the authors of that project to implement it. The linked duplicate answers that. Apr 8, 2019 at 16:17

0

Browse other questions tagged .