doddoreul / google-code-prettify

Automatically exported from code.google.com/p/google-code-prettify
Apache License 2.0
0 stars 0 forks source link

HTML detection not as expected or detected inconsistently #142

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
>> What steps will reproduce the problem?

1. Create an xhtml page with a pre tag containing some html with inline CSS.

2. Follow the instructions as described in the readme file:
http://google-code-prettify.googlecode.com/svn/trunk/README.html

3. Please refer to the attached file:
* prettify-test-case.html

>> What is the expected output? What do you see instead?

The script prettifies the html code inconsistently. This is best illustrated by 
the attached screen shots:

* prettify-unexpected-output.png
* prettify-expected-output.png

Upon close look, you will see that the prettify highlights the same block of 
code differently. For example, it is pretty obvious that in the unexpected 
version, "background-color" is highlighted as pln-pun-pln, where as in the 
expected version, the same is highlighted as kwd.

Both pages use same version of code. However, the page that shows "expected" 
behavior loads lang-css.js, lang-vb.js and lang-sql.js. The <pre> element in 
both cases contains the class "prettyprint".

>> What version are you using?  On what browser?

In both cases I am using:
* prettify r120 by mikesamuel on Nov 16, 2010
* FireFox 3.6.15

Original issue reported on code.google.com by schwarze...@hotmail.com on 19 Mar 2011 at 9:45

Attachments:

GoogleCodeExporter commented 8 years ago
P.S: Specifying the class lang-htm/lang-html on the <pre class="prettyprint"> 
does not have any effect.

Expected behavior in this case: the entire style attribute should be 
highlighted as "atv".

What I see instead: same as described in screen shot 
prettify-unexpected-output.png

Original comment by schwarze...@hotmail.com on 19 Mar 2011 at 10:02

GoogleCodeExporter commented 8 years ago
Please try adding lang-css.js to the set of scripts you load to get CSS 
language highlighting : 
http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-css.j
s

Original comment by mikesamuel@gmail.com on 21 Mar 2011 at 4:40

GoogleCodeExporter commented 8 years ago
Loading lang-css.js but not specifying lang-css class on the <pre> works.

However, I still think that if there is no lang-css.js file loaded, prettify 
should highlight the entire style attribute as "attribute value". See attached 
file. I think the style attribute should have been formatted just like the 
class attribute.

On the other hand, if prettify does this intentionally so that inline styles 
could also be color coded, you can close this issue.

Original comment by schwarze...@hotmail.com on 22 Mar 2011 at 6:05

Attachments:

GoogleCodeExporter commented 8 years ago
Can you try adding

<script type="text/javascript" 
src="http://google-code-prettify.googlecode.com/svn/trunk/src/lang-css.js"></scr
ipt>

after

<script type="text/javascript" 
src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></scr
ipt>

and see if that addresses your problem.  That is the language handler for CSS.

Original comment by mikesamuel@gmail.com on 4 Apr 2011 at 5:44

GoogleCodeExporter commented 8 years ago
Yes, loading lang-css.js color codes the HTML code as expected. Do read comment 
#3.

Original comment by schwarze...@hotmail.com on 5 Apr 2011 at 5:47

GoogleCodeExporter commented 8 years ago
Ah, I must've glossed over comment 3.  I'll look into ways to do what you 
suggest.  I'm not sure quite now how much it'll require increasing the download 
size.

I think I also need to make it easy for people to automatically get lang-css.js 
since an awful lot of people do want HTML highlighting.

Original comment by mikesamuel@gmail.com on 5 Apr 2011 at 5:10

GoogleCodeExporter commented 8 years ago
Thanks. I am not sure if this has something to do with download size. If 
lang-css.js is not present, highlight the entire style attribute just like any 
other attribute e.g. "class" and "id". If lang-css.js is loaded, continue with 
current behavior.

Dreamweaver and Visual Studio 2008 highlight inline styles but rather naively. 
This is how prettify behaves when lang-css.js is loaded but it does a far more 
better job compared to these. Visual Studio prior to 2008 and Notepad++ on the 
other hand highlight the entire style attribute in one color, this behavior I'd 
expect from prettify if lang-css.js is not loaded.

I cannot say about others but I explicitly load lang-css.js when my HTML code 
contains inline styles.

Original comment by schwarze...@hotmail.com on 6 Apr 2011 at 6:03