14

Currently, the tag does not automatically apply any syntax highlighting.

I have reviewed these 2 posts:

Meta SE - What is syntax highlighting and how does it work?

Meta SO - What is syntax highlighting and how does it work?

To save time I am trying to answer some of the FAQ from these posts:

If your post doesn't have the correct highlighting, it's possible it's not supported. Please look at the list of supported languages.

It isn't exactly a new language since it is comprised of multiple languages that already work. Does that matter?

If you're curious whether a tag has a language hint, any user is capable of checking by visiting that tag's wiki page. The language hint (if any) that is currently being used for that tag will be displayed at the very bottom, below the buttons for the wiki:

Currently has no inference set and I'm not sure what inference should be added.


There doesn't seem to be an issue on the code-prettify project GitHub yet. However, I don't know whether to open the issue there or not because I am unsure if we need a new language tag or if we should have a whole new language ruleset or if the language should be inferred from the tag.

Simply tagging might not infer enough because it is a combination of JS/CSS/HTML and I suppose HTML could be run through the JS parser or vice versa.

Additionally, there are varying ways to write Vue code, you can write standalone JS and HTML templates using the runtime version, or you can write single file Vue components that combine all three pieces. I don't know how you could infer this syntax. It would effectively have to look like the default runnable snippet template but without the <!-- language: lang-or-tag-here --> mixed in which causes even more loss of context.

What I have been doing whenever I run across Vue questions that don't have any highlighting is just adding the language code manually. This works, but is cumbersome.

I suppose my question boils down to:

  1. How should Vue syntax highlighting with prettify be addressed?
  2. Where should effort (if any) be documented? Here on Meta? As an issue in the GitHub? Somewhere else?
  3. Are there other language frameworks that face something similar? How did they address it?
4
  • 4
    Realistically, it can't. The language "detection" is just like setting a specific <!-- language-all: ... --> tag at the top of the question based on the tags. As with the snippets and e.g. Angular, which also mixes HTML, CSS and JS/TS (although not always in one file), I don't see a better option for Vue than tagging the separate parts appropriately.
    – jonrsharpe
    Commented Jul 16, 2018 at 19:24
  • 4
    Is there a particular language that will appear most in vue-related questions? I would imagine that highlighting the javascript part is the most valuable so that could be an easy best-effort setting. Lets keep in mind that highlighting is a bonus that makes things a little easier on the eyes, it is not a necessity to be able to read and understand a piece of content. Proper formatting and spacing is still king there. If there is no addressing this then there is no man overboard.
    – Gimby
    Commented Jul 17, 2018 at 11:55
  • @Gimby I agree that this isn't the worst problem in the world, and simply adding the language annotation at the beginning of the code black has worked fine. I was just hoping that there might be an easy path forward. As for what language would be most appropriate, JS and HTML are the most likely. Why is it that I sometimes see HTML markup correctly highlighted even when only JavaScript is tagged?
    – zero298
    Commented Jul 17, 2018 at 15:49
  • Note that Github Flavored Markdown is able to do vue syntax highlighting in code blocks; see github.com/github/linguist/blob/… and docs.github.com/en/github/writing-on-github/…
    – Myer
    Commented May 7, 2021 at 19:09

0

You must log in to answer this question.

Browse other questions tagged .