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

On 2/20/12 7:42 PM, Kang-Hao (Kenny) Lu wrote:
> (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

Yes, that's the idea.

> (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].

Well, it's only for the innerHTML of the root tag.
So that'd still show the string: "<p>"

> 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.

Yeah, it doesn't seem particularly useful without syntax highlighting, 
and even then, it's a real stretch to mix @contenteditable and generated 
content.
I'm just looking for a way to quickly/easily show content to the user.

Using javascript to accomplish it is not a big deal:
node.appendChild(document.createElement('div').appendChild(document.createTextNode(node.innerHTML)).parentNode).className='html';

I just figure it might be helpful in the long term to examine and/or 
address that use case in a CSS world.
I believe it could be a time saver, but that's about it.


-Charles

Received on Tuesday, 21 February 2012 06:16:21 UTC