autodetect issues with HTML -- why isn't "language-html" recognized?

111 views
Skip to first unread message

yroc

unread,
Jan 16, 2013, 12:25:47 PM1/16/13
to highl...@googlegroups.com
Hi,

Firstly, thanks to you all for this great JS library. 

I'm highlighting mainly HTML snippets, but experiencing the occasional highlighting error. In some snippets, small words like "is," "in," and "do" that are inside of paragraphs are getting highlighted. All my <code> elements have the class name "language-html", which obviously isn't recognized by highlighter.js. I tried "language-xml" as you suggested in the documentation, and this does indeed stop the highlighting errors. However, the snippets I'm using are HTML, which is *not* an XML application, and I don't want to mislabel the snippets XML just for the sake of avoiding highlighting errors.

You say that HTML5 recommends certain class name like "language-xml" and "language-php" I assume you're just referring to the format "language-*" and not an actual list of approved language names (please correct me if I'm mistaken, but I didn't see any such list in the spec). So, could you add the class name "language-html" to highlight.js

Thank you,

Ivan Sagalaev

unread,
Jan 19, 2013, 1:47:56 AM1/19/13
to highl...@googlegroups.com
Hi!

> However, the snippets I'm using are HTML, which is
> *not* an XML application, and I don't want to mislabel the snippets XML
> just for the sake of avoiding highlighting errors.

Don't put too much meaning into this "label". This is an internal syntax
identifier in higlight.js and "xml" doesn't imply that the code is a
correct XML in any way. It just so happened that both XML and HTML
highlighting are implemented as a single syntax definition and it
happens to have the "xml" identifier.

> You say that HTML5 recommends certain class name like "language-xml" and
> "language-php" I assume you're just referring to the format "language-*"
> and not an actual list of approved language names (please correct me if
> I'm mistaken, but I didn't see any such list in the spec). So, could you
> add the class name "language-html" to highlight.js

HTML5 recommends using "language-" without further specifying its
meaning. This is nothing more than a loose convention that might be
useful to some tools.

I don't see any practical purpose in introducing an alias for a language
identifier.
Reply all
Reply to author
Forward
0 new messages