Live data from Hacker News

PrismJS

prismjs.com

21–26 of 26 posts

Re: PrismJS

#21
post #20

If you want an even smaller (sans jQuery) JS highlighter that doesn't fail on edge cases, check my jQueryJSH: http://www.phoboslab.org/files/jquery-jsh/ github: https://github.com/phoboslab/jQuery-JSH

1) How do I know it doesn't fail on the same edge cases Prism might fail on? I see no tests. 2) Do you really need jQuery there? You seem to be using it only for the html method, and including 93K extra JS instead of just using innerHTML seems a bit overkill.

2) Do you really need jQuery there? You seem to be using it only for the html method, and including 93K extra JS instead of just using innerHTML seems a bit overkill.

It checks for the case that .innerHTML setting is not supported (I think that was for certain versions of IE) and switches to using appendChild(). I think that that small oversight is somewhat reasonable justification for using a wrapper that abstracts away the browser differences, although it can be argued that once someone understands the differences, they could just add the use cases to their code.

Re: PrismJS

#22

If you want an even smaller (sans jQuery) JS highlighter that doesn't fail on edge cases, check my jQueryJSH: http://www.phoboslab.org/files/jquery-jsh/ github: https://github.com/phoboslab/jQuery-JSH

But smaller does not always mean better. Benchmarks have shown that parsers based exclusively on regular expressions can be even several times slower than parsers that use scanner/tokenizer.

The bigger regExps you write, the slower and more bug-prone your code will be.

Re: PrismJS

#23
post #19
post #15

I don't think the author really understands IE usage patterns. The majority of IE6 usage isn't individuals who don't know better, its companies who should know better. Hence, you'll still get plenty of intelligent coders using IE.

Intelligent coders should know better than to be forced to work with IE6. What would be the server side technology in this case? JSP filled with code and SQL or ASP classic?

Um....no. Intelligent coders understand that there are always limitations placed on them and accept that to produce quality code, they need to understand their environment and code for the end user.

Re: PrismJS

#25
post #20

If you want an even smaller (sans jQuery) JS highlighter that doesn't fail on edge cases, check my jQueryJSH: http://www.phoboslab.org/files/jquery-jsh/ github: https://github.com/phoboslab/jQuery-JSH

1) How do I know it doesn't fail on the same edge cases Prism might fail on? I see no tests. 2) Do you really need jQuery there? You seem to be using it only for the html method, and including 93K extra JS instead of just using innerHTML seems a bit overkill.

I am somewhat confused why you would trust tests for edge cases sufficiently strongly so as to distrust an implementation without any; edge cases should be proved from first principals, as you can't possible test all of them.

Re: PrismJS

#26
I'm confused. In the features list: "Prism forces you to use the correct element for marking up code: ."

But the site's index.html is using only a pre tag:

  

The Prism source, highlighted with Prism (don’t you just love how meta this is?):

It looks like the script is automatically expanding this, inserting tags along with the named file, but I don't see any documentation for doing it this way.

Also, if anyone is as confused as I was about why there's a "data-src" attribute, apparently it's an HTML5 data attribute: http://ejohn.org/blog/html-5-data-attributes/

Post reply on HN