Re: Consider adding content(html) to display html source

(12/02/20 15:49), Daniel Glazman wrote:
> [snip]
>> Something in CSS would it easier to flip on and off HTML source code
>> examples.
>>
>> Something more heavy could display syntax highlighting, if it's not
>> being set to a string.
>> code { content: html(); }
> 
> This is, in my humble opinion, the wrong place to solve this.
> in your <code> example above, you want <code> to behave like
> a normal element on one hand, like a CDATA section on the other...
> It's _NOT_ only a question of presentation, it's a question of
> parsing.

If I understand correctly, 'content: html' wouldn't affect parsing at
all but innerHTML is used as generated content. This means that

(12/02/20 13:03), Charles Pritchard wrote:
> Examples:
> <code><p>I am abusing the code tag</p></code>

would not work if what's in <code> is tag soup, say <code><p></code>
with code { content: html; } would render nothing. So for this scenario,
what you need is <xmp>[1].

For the @contenteditable scenario, it's not clear why you want to make
the HTML source visible (if you want to copy the source than I think the
Clipboard API can partially solve your need). In any case, showing HTML
source without syntax highlighting seems unacceptable in contemporary
website, so this idea seems to depend on whether browsers can support
HTML syntax highlighting on browser side.

I do think it would be useful if browsers provide HTML syntax
highlighting on browser side as I don't think server tools can get HTML
parsing exactly as specced in the HTML spec any time sooner. Making
syntax highlighting stylable by the authors is an important requirement
for this feature, and it sounds... pretty difficult to fulfill .

[1] https://www.w3.org/Bugs/Public/show_bug.cgi?id=12235


Cheers,
Kenny

Received on Tuesday, 21 February 2012 03:42:36 UTC