doddoreul / google-code-prettify

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

Bad formatting of the internals of <script> tags #77

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
try to render the following template
<xmp class="prettyprint">
<script type="text/os-template" name="product-list-template">
  <table>
    <tr>
      <td>
        <p>Price: ... </p>
        <p>Description: ...</p>
      </td>
    </tr>
  </table>
</script>
</xmp>

Note that this is a <script> tag with type="text/os-template" - i.e. it
contains code for OpenSocial Template http://ostemplates-demo.appspot.com/,
not Javascript.

What is the expected output?  What do you see instead?
Note that closing </p> after Price:... and up till closing </td></ is
rendered green.

What version are you using?  On what browser?
http://google-code-prettify.googlecode.com/files/prettify-small-8-Jan-2009.zip
Same problem on FF3, IE6, Safari.

Please provide any additional information below.
Changing <script> tag to something else removes the rendering problems.

Please note that I'm using <xmp> tag in order to present HTML source and
not having to deal with &lt; &gt;.

Original issue reported on code.google.com by bmiz...@google.com on 21 May 2009 at 6:56

GoogleCodeExporter commented 8 years ago
How would you expect the contents of a SCRIPT tag to be formatted?
Is text/os-template XML or HTML+tags?
Should I just not format scripts with a non-standard type?

Original comment by mikesamuel@gmail.com on 14 Aug 2009 at 6:02

GoogleCodeExporter commented 8 years ago
text/os-template is xml.

While I understand that non-javascript <script> is quite unusual, this is a 
part of
the standard :)

I would suggest the ability to specify how to format a specific script type, 
with
some reasonable defaults - i.e. javascript for missing type, no formatting for
unknown types.

Thank you.

Original comment by bmiz...@google.com on 14 Aug 2009 at 6:12

GoogleCodeExporter commented 8 years ago
text/os-template is not part of any standard.

Original comment by mikesamuel@gmail.com on 14 Aug 2009 at 7:50

GoogleCodeExporter commented 8 years ago
I meant that the HTML standard permits non-javascript <script> type.
http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.2

Original comment by bmiz...@google.com on 14 Aug 2009 at 8:37

GoogleCodeExporter commented 8 years ago
Yes, I know.  I was involved in
http://groups.google.com/group/opensocial-and-gadgets-spec/browse_thread/thread/
97ab60942eadfd8c

How would you specify how to format a specific script type?

Original comment by mikesamuel@gmail.com on 14 Aug 2009 at 8:49

GoogleCodeExporter commented 8 years ago
My preference would be 
<script type="some-type" prettify-lang="xml">
  xml goes here
</script>

In fact this could be a generic mechanism - i.e.
<pre prettify-lang="c++">
   some c++ code here
</pre>

Boris

Original comment by bmiz...@google.com on 14 Aug 2009 at 9:08

GoogleCodeExporter commented 8 years ago
For the latter there is already a mechanism.  See the second question in the 
FAQ:
http://google-code-prettify.googlecode.com/svn/trunk/README.html

I also think this library should prettify source code as it is, not extend the
language to make it easier to prettify.

Original comment by mikesamuel@gmail.com on 14 Aug 2009 at 9:16

GoogleCodeExporter commented 8 years ago

Original comment by mikesamuel@gmail.com on 19 Jul 2010 at 9:02