3

Is there a syntax highlighting language hint (<!-- language: lang-??? -->) for Java properties? Or can a hint for another language/format be used for this purpose?

Example snippet to which syntax highlighting is to be added:

# line comment
! also a line comment (but less commonly used)
key1 = value A
key2=value B
key\ with\ spaces = lorem ipsum
url = https://meta.stackoverflow.com/
multi.line = multi \
          line value!
unicode = tab\u0009separated\u0009value

Update:

This question is not a duplicate of the very general question What is syntax highlighting and how does it work? I know the list of supported language hints and I tried all of them without success before I asked this question. Unfortunately, the list is incomplete: for example, lang-xquery which is supported by Stack Overflow is missing.

However, the language hint I know that comes closest is lang-ini (also missing on the list):

<!-- language: lang-ini -->

# line comment
! also a line comment (but less commonly used)
key1 = value A
key2=value B
key\ with\ spaces = lorem ipsum
url = https://meta.stackoverflow.com/
multi.line = multi \
          line value!
unicode = tab\u0009separated\u0009value

In cases with URLs as values or with ! ... line comments I would prefer <!-- language: lang-none --> instead.

3

1 Answer 1

2

No. The languages supported by our syntax highlighting engine are listed here.

There is obviously nothing for Java .properties files, and I don't see anything that would be suitable.

Perhaps Bash comes closest; at least it gets the most common form of line comments correct?

18
  • If nothing matches lang-none might be the least confusing ...
    – rene
    Commented Oct 22, 2017 at 8:38
  • 1
    Indeed. Is there a tag that this is associated with? If so, I can make lang-none the default syntax highlighting for that tag. I didn't find one, though. No [java-properties], and [properties] is much more general.
    – Cody Gray Mod
    Commented Oct 22, 2017 at 8:39
  • The syntax highlighting engine list seems to me to be incomplete, at least lang-query is missing.
    – howlger
    Commented Oct 22, 2017 at 8:42
  • I suspect that questions would 9 out 10 also be tagged with java in which case the major tag's language hint takes precedence. I wouldn't bother.
    – rene
    Commented Oct 22, 2017 at 8:42
  • @howlger not every available lang gets included in the SE supported set.
    – rene
    Commented Oct 22, 2017 at 8:43
  • @rene What do you mean by included? Added to the syntax highlighting engine list or can not be used?
    – howlger
    Commented Oct 22, 2017 at 8:46
  • 1
    There are languages supported by Google Code Prettify that are not supported by the fork of Prettify that Stack Exchange uses. I'm not sure how this decision is made. Probably balancing frequency of usage with size of the JavaScript payload being downloaded on each request. You can ask the team to add support for a language if it's supported by Google Code Prettify by posting a [feature-request], as was done here for Swift. @howlger
    – Cody Gray Mod
    Commented Oct 22, 2017 at 8:52
  • @howlger the SE devs hand pick the lang extensions they want to include/support on the site. They don't do a pull of the Github repo and then bundle everything found in there. So a lang extension being available in the GitHub repo doesn't mean it is missing, it means either no-one requested support for it, or in testing that particular lang extension caused trouble.
    – rene
    Commented Oct 22, 2017 at 8:53
  • @rene Note, with Java syntax highlighting values that contains // (e. g. URLs) will be partly displayed as comments.
    – howlger
    Commented Oct 22, 2017 at 8:54
  • @howlger yes, programming languages are not parse-able by a regular expression, which is what prettify mainly uses. So it will stumble now and then.
    – rene
    Commented Oct 22, 2017 at 8:57
  • @CodyGray lang-xq is supported by Stack Overflow but it is not on the list (I tried to add it to the list, but it doesn't seem to have been accepted).
    – howlger
    Commented Oct 22, 2017 at 9:15
  • @howlger I see no evidence that lang-xq is supported by Stack Overflow. Where did you find that? It is causing the code to be highlighted with the default highlighter.
    – Cody Gray Mod
    Commented Oct 22, 2017 at 9:21
  • @rene As you said before, most questions are tagged with [java]. If values contain URLs it looks worse with than without Java syntax highlighting. As a workaround <!-- language: lang-none --> must be added manually.
    – howlger
    Commented Oct 22, 2017 at 9:21
  • @CodyGray I don't think so. If I add a XQuery snippet to my question here, it will be not highlighted. Also with <!-- language: lang-none --> or <!-- language: lang-foo --> the snippet is not highlighted. In contrast, with <!-- language: lang-xq --> the snippet is highlighted. From this I conclude that lang-xq is supported by Stack Overflow.
    – howlger
    Commented Oct 22, 2017 at 9:28
  • @howlger that is strange because there is no lang-xq here. I expect you see lang-default and I explain here what that does.
    – rene
    Commented Oct 22, 2017 at 9:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .