[whatwg] Ongoing work on an editing commands (execCommand()) specification

Markus Ernst derernst at gmx.ch
Sun Mar 13 14:20:36 PDT 2011


Am 13.03.2011 21:46 schrieb Aryeh Gregor:

> 2) How much work should we go to to produce nice-looking markup?
> E.g., if the user unbolds "baz" in
>
> <div style="font-weight:bold">
> <p>Foo
> <p>Bar baz
> </div>
>
> should we produce something like
>
> <div>
> <p style="font-weight: bold">Foo
> <p><b>Bar</b>baz
> </div>
>
> like WebKit does, or would it be okay to do
>
> <div style="font-weight:bold">
> <p>Foo
> <p>Bar<span style="font-weight: normal">baz</span>
> </div>
>
> to avoid the complexity, given that this sort of markup shouldn't be
> too common?  I think it's clear that something like "<b>Foo baz
> bar</b>" should become"<b>Foo</b>baz<b>  bar</b>" and not"<b>Foo
> <span style='font-weight: normal'>baz</span>  bar</b>", but how far
> should we go?

IMO, from the moment you decide to use <b> and not style="bold" (be it 
due to a user selectable mode or not), style="bold" should actually be 
totally avoided. Thus, the CSS bolding in your example should be 
replaced by <b> tags:

<div>
<p><b>Foo</b>
<p><b>Bar</b> baz
</div>

I think that the code generated should be homogeneous, independent from 
the original markup (which may be copy-/pasted from various sources). 
That means, the bolding in your example would be changed to <b> already 
when the contenteditable element is built, or when the fragment is 
pasted in.



More information about the whatwg mailing list