Bug 25833 - Page that performs syntax highlighting on <code> elements in JS looks wrong when loaded from web archive
Summary: Page that performs syntax highlighting on <code> elements in JS looks wrong w...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL: http://guides.rubyonrails.org/i18n.html
Keywords: NeedsReduction
Depends on:
Blocks:
 
Reported: 2009-05-16 01:51 PDT by Reiner Pittinger
Modified: 2009-05-16 22:48 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Reiner Pittinger 2009-05-16 01:51:18 PDT
When saving a page with a <code>-element, the saved page is displayed incorrectly when viewing the saved archive.

Reproduce:

1. Go to http://guides.rubyonrails.org/i18n.html
2. Look at the correctly displayed code block (below "1.2 The Public I18n API").
3. Save the website as a webarchive.
4. Open the archive and look at the same document part again. Now you will see text like " class="comment">", which is actually a broken <span>-element.
Comment 1 Mark Rowe (bdash) 2009-05-16 02:05:32 PDT
Looking in the web inspector, the markup for the code block on the original page looks like so:
<div class="code_container"><code class="ruby">
translate <span class="comment"># Lookup text translations</span>
localize  <span class="comment"># Localize Date and Time objects to local formats</span>
</code></div>

This matches what is in the document source.  When loaded from the web archive, the markup for the code block looks like so:
<div class="code_container"><code class="ruby">
translate <span><span class="keywords">class</span>=<span class="string">"comment"</span>&gt;<span class="comment"># Lookup text translations</span></span>
localize  <span><span class="keywords">class</span>=<span class="string">"comment"</span>&gt;<span class="comment"># Localize Date and Time objects to local formats</span></span>
</code></div>

Looking at the source of the main resource via View -> Source shows the original, correct markup.
Comment 2 Mark Rowe (bdash) 2009-05-16 02:10:06 PDT
I was mistaken:  the markup in the original page looks like:
<div class="code_container"><code class="ruby">
translate # Lookup text translations
localize  # Localize Date and Time objects to local formats
</code></div>

Since the DOM being displayed contains extra elements related to syntax highlighting, I suspect there is syntax highlighting being performed via JavaScript.  When saving as a web archive we serialize from the DOM at that point in time.  When the document is then loaded once more the syntax highlighting is run on the already-highlighted element, which causes it to attempt to highlight the presentational markup that the earlier syntax highlighting introduced.
Comment 3 Mark Rowe (bdash) 2009-05-16 02:10:52 PDT
I知 not sure whether this is really a bug.
Comment 4 Mark Rowe (bdash) 2009-05-16 22:48:01 PDT
Brady, what do you think we should do with this?