Convert orphaned <li>s to paragraphs
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Tue, 31 May 2011 11:51:02 -0600
changeset 210 f66df0922c5c
parent 209 05af1d9647d7
child 211 725c3edf27ce
Convert orphaned <li>s to paragraphs

Instead of just removing them. This matches the new approach of using
<p> instead of <br> as a line separator. There's still a bug that
remains to be fixed: <li>foo<br>bar</li> becomes <p>foo</p><p>bar</p>
instead of <p>foo<br>bar</p>.
editcommands.html
implementation.js
source.html
--- a/editcommands.html	Tue May 31 11:49:08 2011 -0600
+++ b/editcommands.html	Tue May 31 11:51:02 2011 -0600
@@ -100,15 +100,16 @@
    <li><a href=#block-formatting-command-definitions><span class=secno>7.1 </span>Block formatting command definitions</a></li>
    <li><a href=#assorted-block-formatting-command-algorithms><span class=secno>7.2 </span>Assorted block formatting command algorithms</a></li>
    <li><a href=#block-extending-a-range><span class=secno>7.3 </span>Block-extending a range</a></li>
-   <li><a href=#outdenting-a-node><span class=secno>7.4 </span>Outdenting a node</a></li>
-   <li><a href=#toggling-lists><span class=secno>7.5 </span>Toggling lists</a></li>
-   <li><a href=#the-formatblock-command><span class=secno>7.6 </span>The <code title="">formatBlock</code> command</a></li>
-   <li><a href=#the-indent-command><span class=secno>7.7 </span>The <code title="">indent</code> command</a></li>
-   <li><a href=#the-inserthorizontalrule-command><span class=secno>7.8 </span>The <code title="">insertHorizontalRule</code> command</a></li>
-   <li><a href=#the-insertorderedlist-command><span class=secno>7.9 </span>The <code title="">insertOrderedList</code> command</a></li>
-   <li><a href=#the-insertparagraph-command><span class=secno>7.10 </span>The <code title="">insertParagraph</code> command</a></li>
-   <li><a href=#the-insertunorderedlist-command><span class=secno>7.11 </span>The <code title="">insertUnorderedList</code> command</a></li>
-   <li><a href=#the-outdent-command><span class=secno>7.12 </span>The <code title="">outdent</code> command</a></ol></li>
+   <li><a href=#block-formatting-a-node-list><span class=secno>7.4 </span>Block-formatting a node list</a></li>
+   <li><a href=#outdenting-a-node><span class=secno>7.5 </span>Outdenting a node</a></li>
+   <li><a href=#toggling-lists><span class=secno>7.6 </span>Toggling lists</a></li>
+   <li><a href=#the-formatblock-command><span class=secno>7.7 </span>The <code title="">formatBlock</code> command</a></li>
+   <li><a href=#the-indent-command><span class=secno>7.8 </span>The <code title="">indent</code> command</a></li>
+   <li><a href=#the-inserthorizontalrule-command><span class=secno>7.9 </span>The <code title="">insertHorizontalRule</code> command</a></li>
+   <li><a href=#the-insertorderedlist-command><span class=secno>7.10 </span>The <code title="">insertOrderedList</code> command</a></li>
+   <li><a href=#the-insertparagraph-command><span class=secno>7.11 </span>The <code title="">insertParagraph</code> command</a></li>
+   <li><a href=#the-insertunorderedlist-command><span class=secno>7.12 </span>The <code title="">insertUnorderedList</code> command</a></li>
+   <li><a href=#the-outdent-command><span class=secno>7.13 </span>The <code title="">outdent</code> command</a></ol></li>
  <li><a href=#miscellaneous-commands><span class=secno>8 </span>Miscellaneous commands</a>
   <ol>
    <li><a href=#the-stylewithcss-command><span class=secno>8.1 </span>The <code title="">styleWithCSS</code> command</a></li>
@@ -2859,21 +2860,24 @@
   parent is now a ul.  Chrome 12 dev strips it even if the parent is now an ol.
   The spec makes more sense. -->
 
-  <li>If <var title="">node</var> is an <code class=external data-anolis-spec=html title="the li element"><a href=http://www.whatwg.org/html/#the-li-element>li</a></code> with no attributes and its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> is
-  not an <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code> or <code class=external data-anolis-spec=html title="the ul element"><a href=http://www.whatwg.org/html/#the-ul-element>ul</a></code>, or is a <code class=external data-anolis-spec=html title="the dt element"><a href=http://www.whatwg.org/html/#the-dt-element>dt</a></code> or <code class=external data-anolis-spec=html title="the dd element"><a href=http://www.whatwg.org/html/#the-dd-element>dd</a></code> with no attributes and its
-  <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> is not a <code class=external data-anolis-spec=html title="the dl element"><a href=http://www.whatwg.org/html/#the-dl-element>dl</a></code>, remove <var title="">node</var>, <a href=#preserving-its-descendants>preserving its
-  descendants</a>.  Then abort these steps.
-
   <li>If <var title="">node</var> is an <code class=external data-anolis-spec=html title="the li element"><a href=http://www.whatwg.org/html/#the-li-element>li</a></code> and its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> is not an <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code> or
-  <code class=external data-anolis-spec=html title="the ul element"><a href=http://www.whatwg.org/html/#the-ul-element>ul</a></code>, or is a <code class=external data-anolis-spec=html title="the dt element"><a href=http://www.whatwg.org/html/#the-dt-element>dt</a></code> or <code class=external data-anolis-spec=html title="the dd element"><a href=http://www.whatwg.org/html/#the-dd-element>dd</a></code> and its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> is not a <code class=external data-anolis-spec=html title="the dl element"><a href=http://www.whatwg.org/html/#the-dl-element>dl</a></code>,
-  <a href=#set-the-tag-name>set the tag name</a> of <var title="">node</var> to "div".  Then abort these
-  steps.
-
-  <p class=XXX>Should convert it to the default single-line container type.
-
-  <li>If <var title="">node</var> is an <a href=#allowed-child>allowed child</a> of its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>, or
-  it is not an <a href=#allowed-child>allowed child</a> of any of its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-ancestor title=concept-tree-ancestor>ancestors</a> <a href=#in-the-same-editing-host>in
-  the same editing host</a>, abort these steps and do nothing.
+  <code class=external data-anolis-spec=html title="the ul element"><a href=http://www.whatwg.org/html/#the-ul-element>ul</a></code>, or <var title="">node</var> is a <code class=external data-anolis-spec=html title="the dt element"><a href=http://www.whatwg.org/html/#the-dt-element>dt</a></code> or <code class=external data-anolis-spec=html title="the dd element"><a href=http://www.whatwg.org/html/#the-dd-element>dd</a></code> and its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> is not a
+  <code class=external data-anolis-spec=html title="the dl element"><a href=http://www.whatwg.org/html/#the-dl-element>dl</a></code>:
+
+  <ol>
+    <li>Let <var title="">children</var> be the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>children</a> of <var title="">node</var>.
+
+    <li>Remove <var title="">node</var>, <a href=#preserving-its-descendants>preserving its descendants</a>.
+
+    <li><a href=#block-format>Block-format</a> <var title="">children</var>, with <var title="">value</var>
+    equal to the <a href=#default-single-line-container-name>default single-line container name</a>.
+
+    <li>Abort these steps.
+  </ol>
+
+  <li>If <var title="">node</var> is not an <a href=#allowed-child>allowed child</a> of any of its
+  <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-ancestor title=concept-tree-ancestor>ancestors</a> <a href=#in-the-same-editing-host>in the same editing host</a>, abort these steps and do
+  nothing.
 
   <li>While <var title="">node</var> is not an <a href=#allowed-child>allowed child</a> of its
   <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>, <a href=#split-the-parent>split the parent</a> of the one-<a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a> list consisting
@@ -3122,7 +3126,139 @@
 </ol>
 
 
-<h3 id=outdenting-a-node><span class=secno>7.4 </span>Outdenting a node</h3>
+<h3 id=block-formatting-a-node-list><span class=secno>7.4 </span>Block-formatting a node list</h3>
+
+<p>To <dfn id=block-format>block-format</dfn> a list of <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>nodes</a> <var title="">node list</var> to a
+string <var title="">value</var>:
+
+<ol>
+  <li>For each <var title="">node</var> in <var title="">node list</var>, while <var title="">node</var>
+  is a <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-descendant title=concept-tree-descendant>descendant</a> of an <a href=#editable>editable</a> <a href=#html-element>HTML element</a>
+  <a href=#in-the-same-editing-host>in the same editing host</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> "address", "h1",
+  "h2", "h3", "h4", "h5", "h6", "p", or "pre", <a href=#split-the-parent>split the parent</a> of
+  the one-<a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a> list consisting of <var title="">node</var>.
+
+  <div class=XXX>
+  <p>This is needed so we don't get things like p nested inside address, and
+  instead convert part of the multi-line address into a p.  But div can contain
+  any of these things, so we don't break that apart ever, which is bad.  It
+  means if you have
+
+  </p><xmp><div>foo<br>bar</div></xmp>
+
+  <p>then formatBlocking "foo" then "bar" as p has different results from doing
+  both at once.  Maybe we should split divs as well, but only if they're the
+  parent of the node we're dealing with?  Or just split divs always, and hope
+  the "in the same editing host" thing handles it?
+  </div>
+
+  <p class=XXX>Do we need to fix disallowed ancestors later, or is this step
+  enough that it's not an issue?
+
+  <!--
+  We have two different behaviors, one for div and p and one for everything
+  else.  The basic difference is that for div and p, we assume that it should
+  be one line per element, while for other elements, we put in multiple lines
+  separated by <br>.  So if you do formatBlock to p on
+
+    <div>foo</div><div>bar</div> or
+    foo<br>bar
+
+  you get
+
+    <p>foo</p><p>bar</p>
+
+  but formatBlock to h1 will get you
+
+    <h1>foo<br>bar</h1>.
+
+  IE9 will just change the elements as they are, so it gives
+  <p>foo</p><p>bar</p> and <h1>foo</h1><h1>bar</h1> for
+  <div>foo</div><div>bar</div>, but <p>foo<br>bar</p> and <h1>foo<br>bar</h1>
+  for foo<br>bar.  This is unreasonable, but the two possible inputs here look
+  identical to the user and might have been produced by identical user input.
+
+  Firefox 5.0a2 will give results like <p>foo</p><p>bar</p> or
+  <h1>foo</h1><h1>bar</h1> no matter what (modulo oddities in its handling of
+  divs).  Opera 11.10 is similar, except it leaves a trailing <br> in the first
+  element.
+
+  Chrome 13 dev will give results like <p>foo<br>bar</p> or <h1>foo<br>bar</h1>
+  no matter what.
+
+  The specced behavior is a compromise between the existing behaviors,
+  predicated on the fact that <h1>foo</h1><h1>bar</h1> almost never makes
+  sense, and <p>foo<br>bar</p> isn't usually what's wanted either.
+  -->
+  <li>If <var title="">value</var> is "div" or "p", then while <var title="">node list</var> is
+  not empty:
+
+  <ol>
+    <li>If the first member of <var title="">node list</var> is a <a href=#non-list-single-line-container>non-list
+    single-line container</a>, <a href=#set-the-tag-name>set the tag name</a> of the first
+    member of <var title="">node list</var> to <var title="">value</var>, then remove the first
+    member from <var title="">node list</var> and continue this loop from the beginning.
+
+    <li>Let <var title="">sublist</var> be an empty list of <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>nodes</a>.
+
+    <li>Remove the first member of <var title="">node list</var> and append it to
+    <var title="">sublist</var>.
+
+    <li>While <var title="">node list</var> is not empty, and the first member of
+    <var title="">node list</var> is the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> of the last member of
+    <var title="">sublist</var>, and the first member of <var title="">node list</var> is not a
+    <a href=#non-list-single-line-container>non-list single-line container</a>, and the last member of
+    <var title="">sublist</var> is not a <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/html/#the-br-element>br</a></code>, remove the first member of <var title="">node
+    list</var> and append it to <var title="">sublist</var>.
+
+    <li><a href=#wrap>Wrap</a> <var title="">sublist</var>, with <a href=#sibling-criteria>sibling
+    criteria</a> matching nothing and <a href=#new-parent-instructions>new parent instructions</a>
+    returning the result of running <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement(<var title="">value</var>)</a></code> on the
+    <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>.
+  </ol>
+
+  <li>Otherwise, while <var title="">node list</var> is not empty:
+
+  <ol>
+    <li>If the first member of <var title="">node list</var> is a <a href=#non-list-single-line-container>non-list
+    single-line container</a>:
+
+    <ol>
+      <li>Let <var title="">sublist</var> be the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>children</a> of the first member of
+      <var title="">node list</var>.
+
+      <li>Remove the first member of <var title="">node list</var> from its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>,
+      <a href=#preserving-its-descendants>preserving its descendants</a>.
+
+      <li>Remove the first member from <var title="">node list</var>.
+    </ol>
+
+    <li>Otherwise:
+
+    <ol>
+      <li>Let <var title="">sublist</var> be an empty list of <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>nodes</a>.
+
+      <li>Remove the first member of <var title="">node list</var> and append it to
+      <var title="">sublist</var>.
+
+      <li>While <var title="">node list</var> is not empty, and the first member of
+      <var title="">node list</var> is the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> of the last member of
+      <var title="">sublist</var>, and the first member of <var title="">node list</var> is not a
+      <a href=#non-list-single-line-container>non-list single-line container</a>, and the last member of
+      <var title="">sublist</var> is not a <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/html/#the-br-element>br</a></code>, remove the first member of <var title="">node
+      list</var> and append it to <var title="">sublist</var>.
+    </ol>
+
+    <li><a href=#wrap>Wrap</a> <var title="">sublist</var>, with <a href=#sibling-criteria>sibling
+    criteria</a> matching any <a href=#html-element>HTML element</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a>
+    <var title="">value</var> and no attributes, and <a href=#new-parent-instructions>new parent
+    instructions</a> returning the result of running
+    <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement(<var title="">value</var>)</a></code> on the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>.
+  </ol>
+</ol>
+
+
+<h3 id=outdenting-a-node><span class=secno>7.5 </span>Outdenting a node</h3>
 
 <p>To <dfn id=outdent>outdent</dfn> a <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a> <var title="">node</var>:
 
@@ -3318,7 +3454,7 @@
 </ol>
 
 
-<h3 id=toggling-lists><span class=secno>7.5 </span>Toggling lists</h3>
+<h3 id=toggling-lists><span class=secno>7.6 </span>Toggling lists</h3>
 
 <!--
 Research for insertOrderedList/insertUnorderedList: tested the following
@@ -3843,7 +3979,7 @@
 </ol>
 
 
-<h3 id=the-formatblock-command><span class=secno>7.6 </span><dfn>The <code title="">formatBlock</code> command</dfn></h3>
+<h3 id=the-formatblock-command><span class=secno>7.7 </span><dfn>The <code title="">formatBlock</code> command</dfn></h3>
 <!--
 Tested browser versions: IE9, Firefox 4.0, Chrome 13 dev, Opera 11.10.
 
@@ -3921,133 +4057,11 @@
   <a href=#non-list-single-line-container>non-list single-line container</a> or an <a href=#allowed-child>allowed child</a>
   of "p".
 
-  <li>For each <var title="">node</var> in <var title="">node list</var>, while <var title="">node</var>
-  is a <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-descendant title=concept-tree-descendant>descendant</a> of an <a href=#editable>editable</a> <a href=#html-element>HTML element</a>
-  <a href=#in-the-same-editing-host>in the same editing host</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> "address", "h1",
-  "h2", "h3", "h4", "h5", "h6", "p", or "pre", <a href=#split-the-parent>split the parent</a> of
-  the one-<a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a> list consisting of <var title="">node</var>.
-
-  <div class=XXX>
-  <p>This is needed so we don't get things like p nested inside address, and
-  instead convert part of the multi-line address into a p.  But div can contain
-  any of these things, so we don't break that apart ever, which is bad.  It
-  means if you have
-
-  </p><xmp><div>foo<br>bar</div></xmp>
-
-  <p>then formatBlocking "foo" then "bar" as p has different results from doing
-  both at once.  Maybe we should split divs as well, but only if they're the
-  parent of the node we're dealing with?  Or just split divs always, and hope
-  the "in the same editing host" thing handles it?
-  </div>
-
-  <p class=XXX>Do we need to fix disallowed ancestors later, or is this step
-  enough that it's not an issue?
-
-  <!--
-  We have two different behaviors, one for div and p and one for everything
-  else.  The basic difference is that for div and p, we assume that it should
-  be one line per element, while for other elements, we put in multiple lines
-  separated by <br>.  So if you do formatBlock to p on
-
-    <div>foo</div><div>bar</div> or
-    foo<br>bar
-
-  you get
-
-    <p>foo</p><p>bar</p>
-
-  but formatBlock to h1 will get you
-
-    <h1>foo<br>bar</h1>.
-
-  IE9 will just change the elements as they are, so it gives
-  <p>foo</p><p>bar</p> and <h1>foo</h1><h1>bar</h1> for
-  <div>foo</div><div>bar</div>, but <p>foo<br>bar</p> and <h1>foo<br>bar</h1>
-  for foo<br>bar.  This is unreasonable, but the two possible inputs here look
-  identical to the user and might have been produced by identical user input.
-
-  Firefox 5.0a2 will give results like <p>foo</p><p>bar</p> or
-  <h1>foo</h1><h1>bar</h1> no matter what (modulo oddities in its handling of
-  divs).  Opera 11.10 is similar, except it leaves a trailing <br> in the first
-  element.
-
-  Chrome 13 dev will give results like <p>foo<br>bar</p> or <h1>foo<br>bar</h1>
-  no matter what.
-
-  The specced behavior is a compromise between the existing behaviors,
-  predicated on the fact that <h1>foo</h1><h1>bar</h1> almost never makes
-  sense, and <p>foo<br>bar</p> isn't usually what's wanted either.
-  -->
-  <li>If <var title="">value</var> is "div" or "p", then while <var title="">node list</var> is
-  not empty:
-
-  <ol>
-    <li>If the first member of <var title="">node list</var> is a <a href=#non-list-single-line-container>non-list
-    single-line container</a>, <a href=#set-the-tag-name>set the tag name</a> of the first
-    member of <var title="">node list</var> to <var title="">value</var>, then remove the first
-    member from <var title="">node list</var> and continue this loop from the beginning.
-
-    <li>Let <var title="">sublist</var> be an empty list of <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>nodes</a>.
-
-    <li>Remove the first member of <var title="">node list</var> and append it to
-    <var title="">sublist</var>.
-
-    <li>While <var title="">node list</var> is not empty, and the first member of
-    <var title="">node list</var> is the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> of the last member of
-    <var title="">sublist</var>, and the first member of <var title="">node list</var> is not a
-    <a href=#non-list-single-line-container>non-list single-line container</a>, and the last member of
-    <var title="">sublist</var> is not a <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/html/#the-br-element>br</a></code>, remove the first member of <var title="">node
-    list</var> and append it to <var title="">sublist</var>.
-
-    <li><a href=#wrap>Wrap</a> <var title="">sublist</var>, with <a href=#sibling-criteria>sibling
-    criteria</a> matching nothing and <a href=#new-parent-instructions>new parent instructions</a>
-    returning the result of running <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement(<var title="">value</var>)</a></code> on
-    the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>.
-  </ol>
-
-  <li>Otherwise, while <var title="">node list</var> is not empty:
-
-  <ol>
-    <li>If the first member of <var title="">node list</var> is a <a href=#non-list-single-line-container>non-list
-    single-line container</a>:
-
-    <ol>
-      <li>Let <var title="">sublist</var> be the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>children</a> of the first member of
-      <var title="">node list</var>.
-
-      <li>Remove the first member of <var title="">node list</var> from its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>,
-      <a href=#preserving-its-descendants>preserving its descendants</a>.
-
-      <li>Remove the first member from <var title="">node list</var>.
-    </ol>
-
-    <li>Otherwise:
-
-    <ol>
-      <li>Let <var title="">sublist</var> be an empty list of <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>nodes</a>.
-
-      <li>Remove the first member of <var title="">node list</var> and append it to
-      <var title="">sublist</var>.
-
-      <li>While <var title="">node list</var> is not empty, and the first member of
-      <var title="">node list</var> is the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> of the last member of
-      <var title="">sublist</var>, and the first member of <var title="">node list</var> is not a
-      <a href=#non-list-single-line-container>non-list single-line container</a>, and the last member of
-      <var title="">sublist</var> is not a <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/html/#the-br-element>br</a></code>, remove the first member of <var title="">node
-      list</var> and append it to <var title="">sublist</var>.
-    </ol>
-
-    <li><a href=#wrap>Wrap</a> <var title="">sublist</var>, with <a href=#sibling-criteria>sibling
-    criteria</a> matching any <a href=#html-element>HTML element</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a>
-    <var title="">value</var> and no attributes, and <a href=#new-parent-instructions>new parent
-    instructions</a> returning the result of running <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement(<var title="">value</var>)</a></code> on
-    the <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>.
-  </ol>
+  <li><a href=#block-format>Block-format</a> <var title="">node list</var>.
 </ol>
 
 
-<h3 id=the-indent-command><span class=secno>7.7 </span><dfn>The <code title="">indent</code> command</dfn></h3>
+<h3 id=the-indent-command><span class=secno>7.8 </span><dfn>The <code title="">indent</code> command</dfn></h3>
 <!--
 IE9: Outputs <blockquote style="margin-right: 0px" dir="ltr">, or when
   surrounding RTL blocks, <blockquote style="margin-left: 0px" dir="rtl">.  The
@@ -4150,7 +4164,7 @@
 </ol>
 
 
-<h3 id=the-inserthorizontalrule-command><span class=secno>7.8 </span><dfn>The <code title="">insertHorizontalRule</code> command</dfn></h3>
+<h3 id=the-inserthorizontalrule-command><span class=secno>7.9 </span><dfn>The <code title="">insertHorizontalRule</code> command</dfn></h3>
 
 <p><a href=#action>Action</a>:
 
@@ -4204,13 +4218,13 @@
 </ol>
 
 
-<h3 id=the-insertorderedlist-command><span class=secno>7.9 </span><dfn>The <code title="">insertOrderedList</code> command</dfn></h3>
+<h3 id=the-insertorderedlist-command><span class=secno>7.10 </span><dfn>The <code title="">insertOrderedList</code> command</dfn></h3>
 
 <p><a href=#action>Action</a>: <a href=#toggle-lists>Toggle lists</a> with <var title="">tag name</var>
 "ol".
 
 
-<h3 id=the-insertparagraph-command><span class=secno>7.10 </span><dfn>The <code title="">insertParagraph</code> command</dfn></h3>
+<h3 id=the-insertparagraph-command><span class=secno>7.11 </span><dfn>The <code title="">insertParagraph</code> command</dfn></h3>
 <!--
 There are three major behaviors here.  Firefox 5.0a2 behaves identically to
 execCommand("formatBlock", false, "p"), which is not really useful.  IE9
@@ -4428,13 +4442,13 @@
 </ol>
 
 
-<h3 id=the-insertunorderedlist-command><span class=secno>7.11 </span><dfn>The <code title="">insertUnorderedList</code> command</dfn></h3>
+<h3 id=the-insertunorderedlist-command><span class=secno>7.12 </span><dfn>The <code title="">insertUnorderedList</code> command</dfn></h3>
 
 <p><a href=#action>Action</a>: <a href=#toggle-lists>Toggle lists</a> with <var title="">tag name</var>
 "ul".
 
 
-<h3 id=the-outdent-command><span class=secno>7.12 </span><dfn>The <code title="">outdent</code> command</dfn></h3>
+<h3 id=the-outdent-command><span class=secno>7.13 </span><dfn>The <code title="">outdent</code> command</dfn></h3>
 
 <p><a href=#action>Action</a>:
 
--- a/implementation.js	Tue May 31 11:49:08 2011 -0600
+++ b/implementation.js	Tue May 31 11:51:02 2011 -0600
@@ -2039,6 +2039,124 @@
 	return newRange;
 }
 
+function blockFormat(nodeList, value) {
+	// "For each node in node list, while node is a descendant of an
+	// editable HTML element in the same editing host with local name
+	// "address", "h1", "h2", "h3", "h4", "h5", "h6", "p", or "pre", split
+	// the parent of the one-node list consisting of node."
+	for (var i = 0; i < nodeList.length; i++) {
+		var node = nodeList[i];
+
+		do {
+			var ancestor = node.parentNode;
+			while (ancestor
+			&& !isHtmlElement(ancestor, ["ADDRESS", "H1", "H2", "H3", "H4", "H5", "H6", "P", "PRE"])) {
+				ancestor = ancestor.parentNode;
+			}
+			if (ancestor
+			&& isEditable(ancestor)
+			&& inSameEditingHost(node, ancestor)) {
+				splitParent([node]);
+			} else {
+				break;
+			}
+		} while (true);
+	}
+
+	// "If value is "div" or "p", then while node list is not empty:"
+	if (value == "div" || value == "p") {
+		while (nodeList.length) {
+			// "If the first member of node list is a non-list single-line
+			// container, set the tag name of the first member of node list
+			// to value, then remove the first member from node list and
+			// continue this loop from the beginning."
+			if (isNonListSingleLineContainer(nodeList[0])) {
+				setTagName(nodeList[0], value);
+				nodeList.shift();
+				continue;
+			}
+
+			// "Let sublist be an empty list of nodes."
+			var sublist = [];
+
+			// "Remove the first member of node list and append it to
+			// sublist."
+			sublist.push(nodeList.shift());
+
+			// "While node list is not empty, and the first member of node
+			// list is the nextSibling of the last member of sublist, and
+			// the first member of node list is not a non-list single-line
+			// container, and the last member of sublist is not a br,
+			// remove the first member of node list and append it to
+			// sublist."
+			while (nodeList.length
+			&& nodeList[0] == sublist[sublist.length - 1].nextSibling
+			&& !isNonListSingleLineContainer(nodeList[0])
+			&& !isHtmlElement(sublist[sublist.length - 1], "BR")) {
+				sublist.push(nodeList.shift());
+			}
+
+			// "Wrap sublist, with sibling criteria matching nothing and
+			// new parent instructions returning the result of running
+			// createElement(value) on the context object."
+			wrap(sublist,
+				function() { return false },
+				function() { return document.createElement(value) });
+		}
+
+	// "Otherwise, while node list is not empty:"
+	} else {
+		while (nodeList.length) {
+			var sublist;
+
+			// "If the first member of node list is a non-list single-line
+			// container:"
+			if (isNonListSingleLineContainer(nodeList[0])) {
+				// "Let sublist be the children of the first member of node
+				// list."
+				sublist = [].slice.call(nodeList[0].childNodes);
+
+				// "Remove the first member of node list from its parent,
+				// preserving its descendants."
+				removePreservingDescendants(nodeList[0]);
+
+				// "Remove the first member from node list."
+				nodeList.shift();
+
+			// "Otherwise:"
+			} else {
+				// "Let sublist be an empty list of nodes."
+				sublist = [];
+
+				// "Remove the first member of node list and append it to
+				// sublist."
+				sublist.push(nodeList.shift());
+
+				// "While node list is not empty, and the first member of
+				// node list is the nextSibling of the last member of
+				// sublist, and the first member of node list is not a
+				// non-list single-line container, and the last member of
+				// sublist is not a br, remove the first member of node
+				// list and append it to sublist."
+				while (nodeList.length
+				&& nodeList[0] == sublist[sublist.length - 1].nextSibling
+				&& !isNonListSingleLineContainer(nodeList[0])
+				&& !isHtmlElement(sublist[sublist.length - 1], "BR")) {
+					sublist.push(nodeList.shift());
+				}
+			}
+
+			// "Wrap sublist, with sibling criteria matching any HTML
+			// element with local name value and no attributes, and new
+			// parent instructions returning the result of running
+			// createElement(value) on the context object."
+			wrap(sublist,
+				function(node) { return isHtmlElement(node, value.toUpperCase()) && !node.attributes.length },
+				function() { return document.createElement(value) });
+		}
+	}
+}
+
 function clearValue(element, command) {
 	// "If element's specified value for command is null, return the empty
 	// list."
@@ -2871,121 +2989,8 @@
 				|| isAllowedChild(node, "p"));
 		});
 
-		// "For each node in node list, while node is a descendant of an
-		// editable HTML element in the same editing host with local name
-		// "address", "h1", "h2", "h3", "h4", "h5", "h6", "p", or "pre", split
-		// the parent of the one-node list consisting of node."
-		for (var i = 0; i < nodeList.length; i++) {
-			node = nodeList[i];
-
-			do {
-				var ancestor = node.parentNode;
-				while (ancestor
-				&& !isHtmlElement(ancestor, ["ADDRESS", "H1", "H2", "H3", "H4", "H5", "H6", "P", "PRE"])) {
-					ancestor = ancestor.parentNode;
-				}
-				if (ancestor
-				&& isEditable(ancestor)
-				&& inSameEditingHost(node, ancestor)) {
-					splitParent([node]);
-				} else {
-					break;
-				}
-			} while (true);
-		}
-
-		// "If value is "div" or "p", then while node list is not empty:"
-		if (value == "div" || value == "p") {
-			while (nodeList.length) {
-				// "If the first member of node list is a non-list single-line
-				// container, set the tag name of the first member of node list
-				// to value, then remove the first member from node list and
-				// continue this loop from the beginning."
-				if (isNonListSingleLineContainer(nodeList[0])) {
-					setTagName(nodeList[0], value);
-					nodeList.shift();
-					continue;
-				}
-
-				// "Let sublist be an empty list of nodes."
-				var sublist = [];
-
-				// "Remove the first member of node list and append it to
-				// sublist."
-				sublist.push(nodeList.shift());
-
-				// "While node list is not empty, and the first member of node
-				// list is the nextSibling of the last member of sublist, and
-				// the first member of node list is not a non-list single-line
-				// container, and the last member of sublist is not a br,
-				// remove the first member of node list and append it to
-				// sublist."
-				while (nodeList.length
-				&& nodeList[0] == sublist[sublist.length - 1].nextSibling
-				&& !isNonListSingleLineContainer(nodeList[0])
-				&& !isHtmlElement(sublist[sublist.length - 1], "BR")) {
-					sublist.push(nodeList.shift());
-				}
-
-				// "Wrap sublist, with sibling criteria matching nothing and
-				// new parent instructions returning the result of running
-				// createElement(value) on the context object."
-				wrap(sublist,
-					function() { return false },
-					function() { return document.createElement(value) });
-			}
-
-		// "Otherwise, while node list is not empty:"
-		} else {
-			while (nodeList.length) {
-				var sublist;
-
-				// "If the first member of node list is a non-list single-line
-				// container:"
-				if (isNonListSingleLineContainer(nodeList[0])) {
-					// "Let sublist be the children of the first member of node
-					// list."
-					sublist = [].slice.call(nodeList[0].childNodes);
-
-					// "Remove the first member of node list from its parent,
-					// preserving its descendants."
-					removePreservingDescendants(nodeList[0]);
-
-					// "Remove the first member from node list."
-					nodeList.shift();
-
-				// "Otherwise:"
-				} else {
-					// "Let sublist be an empty list of nodes."
-					sublist = [];
-
-					// "Remove the first member of node list and append it to
-					// sublist."
-					sublist.push(nodeList.shift());
-
-					// "While node list is not empty, and the first member of
-					// node list is the nextSibling of the last member of
-					// sublist, and the first member of node list is not a
-					// non-list single-line container, and the last member of
-					// sublist is not a br, remove the first member of node
-					// list and append it to sublist."
-					while (nodeList.length
-					&& nodeList[0] == sublist[sublist.length - 1].nextSibling
-					&& !isNonListSingleLineContainer(nodeList[0])
-					&& !isHtmlElement(sublist[sublist.length - 1], "BR")) {
-						sublist.push(nodeList.shift());
-					}
-				}
-
-				// "Wrap sublist, with sibling criteria matching any HTML
-				// element with local name value and no attributes, and new
-				// parent instructions returning the result of running
-				// createElement(value) on the context object."
-				wrap(sublist,
-					function(node) { return isHtmlElement(node, value.toUpperCase()) && !node.attributes.length },
-					function() { return document.createElement(value) });
-			}
-		}
+		// "Block-format node list."
+		blockFormat(nodeList, value);
 		break;
 
 		case "indent":
@@ -3687,26 +3692,23 @@
 		node.removeAttribute("value");
 	}
 
-	// "If node is an li with no attributes and its parent is not an ol or ul,
-	// or is a dt or dd with no attributes and its parent is not a dl, remove
-	// node, preserving its descendants. Then abort these steps."
-	if ((isHtmlElement(node, "li")
-	&& !node.attributes.length
-	&& !isHtmlElement(node.parentNode, ["ol", "ul"]))
-	|| (isHtmlElement(node, ["dt", "dd"])
-	&& !node.attributes.length
-	&& !isHtmlElement(node.parentNode, "dl"))) {
-		removePreservingDescendants(node);
-	}
-
-	// "If node is an li and its parent is not an ol or ul, or is a dt or dd
-	// and its parent is not a dl, set the tag name of node to "div". Then
-	// abort these steps."
+	// "If node is an li and its parent is not an ol or ul, or node is a dt or
+	// dd and its parent is not a dl:"
 	if ((isHtmlElement(node, "li")
 	&& !isHtmlElement(node.parentNode, ["ol", "ul"]))
 	|| (isHtmlElement(node, ["dt", "dd"])
 	&& !isHtmlElement(node.parentNode, "dl"))) {
-		setTagName(node, "div");
+		// "Let children be the children of node."
+		var children = [].slice.call(node.childNodes);
+
+		// "Remove node, preserving its descendants."
+		removePreservingDescendants(node);
+
+		// "Block-format children, with value equal to the default single-line
+		// container name."
+		blockFormat(children, defaultSingleLineContainerName);
+
+		// "Abort these steps."
 		return;
 	}
 
--- a/source.html	Tue May 31 11:49:08 2011 -0600
+++ b/source.html	Tue May 31 11:51:02 2011 -0600
@@ -2862,21 +2862,24 @@
   parent is now a ul.  Chrome 12 dev strips it even if the parent is now an ol.
   The spec makes more sense. -->
 
-  <li>If <var>node</var> is an [[li]] with no attributes and its [[parent]] is
-  not an [[ol]] or [[ul]], or is a [[dt]] or [[dd]] with no attributes and its
-  [[parent]] is not a [[dl]], remove <var>node</var>, <span>preserving its
-  descendants</span>.  Then abort these steps.
-
   <li>If <var>node</var> is an [[li]] and its [[parent]] is not an [[ol]] or
-  [[ul]], or is a [[dt]] or [[dd]] and its [[parent]] is not a [[dl]],
-  <span>set the tag name</span> of <var>node</var> to "div".  Then abort these
-  steps.
-
-  <p class=XXX>Should convert it to the default single-line container type.
-
-  <li>If <var>node</var> is an <span>allowed child</span> of its [[parent]], or
-  it is not an <span>allowed child</span> of any of its [[ancestors]] <span>in
-  the same editing host</span>, abort these steps and do nothing.
+  [[ul]], or <var>node</var> is a [[dt]] or [[dd]] and its [[parent]] is not a
+  [[dl]]:
+
+  <ol>
+    <li>Let <var>children</var> be the [[children]] of <var>node</var>.
+
+    <li>Remove <var>node</var>, <span>preserving its descendants</span>.
+
+    <li><span>Block-format</span> <var>children</var>, with <var>value</var>
+    equal to the <span>default single-line container name</span>.
+
+    <li>Abort these steps.
+  </ol>
+
+  <li>If <var>node</var> is not an <span>allowed child</span> of any of its
+  [[ancestors]] <span>in the same editing host</span>, abort these steps and do
+  nothing.
 
   <li>While <var>node</var> is not an <span>allowed child</span> of its
   [[parent]], <span>split the parent</span> of the one-[[node]] list consisting
@@ -3131,6 +3134,138 @@
 </ol>
 
 
+<h3>Block-formatting a node list</h3>
+
+<p>To <dfn>block-format</dfn> a list of [[nodes]] <var>node list</var> to a
+string <var>value</var>:
+
+<ol>
+  <li>For each <var>node</var> in <var>node list</var>, while <var>node</var>
+  is a [[descendant]] of an <span>editable</span> <span>HTML element</span>
+  <span>in the same editing host</span> with [[localname]] "address", "h1",
+  "h2", "h3", "h4", "h5", "h6", "p", or "pre", <span>split the parent</span> of
+  the one-[[node]] list consisting of <var>node</var>.
+
+  <div class=XXX>
+  <p>This is needed so we don't get things like p nested inside address, and
+  instead convert part of the multi-line address into a p.  But div can contain
+  any of these things, so we don't break that apart ever, which is bad.  It
+  means if you have
+
+  <xmp><div>foo<br>bar</div></xmp>
+
+  <p>then formatBlocking "foo" then "bar" as p has different results from doing
+  both at once.  Maybe we should split divs as well, but only if they're the
+  parent of the node we're dealing with?  Or just split divs always, and hope
+  the "in the same editing host" thing handles it?
+  </div>
+
+  <p class=XXX>Do we need to fix disallowed ancestors later, or is this step
+  enough that it's not an issue?
+
+  <!--
+  We have two different behaviors, one for div and p and one for everything
+  else.  The basic difference is that for div and p, we assume that it should
+  be one line per element, while for other elements, we put in multiple lines
+  separated by <br>.  So if you do formatBlock to p on
+
+    <div>foo</div><div>bar</div> or
+    foo<br>bar
+
+  you get
+
+    <p>foo</p><p>bar</p>
+
+  but formatBlock to h1 will get you
+
+    <h1>foo<br>bar</h1>.
+
+  IE9 will just change the elements as they are, so it gives
+  <p>foo</p><p>bar</p> and <h1>foo</h1><h1>bar</h1> for
+  <div>foo</div><div>bar</div>, but <p>foo<br>bar</p> and <h1>foo<br>bar</h1>
+  for foo<br>bar.  This is unreasonable, but the two possible inputs here look
+  identical to the user and might have been produced by identical user input.
+
+  Firefox 5.0a2 will give results like <p>foo</p><p>bar</p> or
+  <h1>foo</h1><h1>bar</h1> no matter what (modulo oddities in its handling of
+  divs).  Opera 11.10 is similar, except it leaves a trailing <br> in the first
+  element.
+
+  Chrome 13 dev will give results like <p>foo<br>bar</p> or <h1>foo<br>bar</h1>
+  no matter what.
+
+  The specced behavior is a compromise between the existing behaviors,
+  predicated on the fact that <h1>foo</h1><h1>bar</h1> almost never makes
+  sense, and <p>foo<br>bar</p> isn't usually what's wanted either.
+  -->
+  <li>If <var>value</var> is "div" or "p", then while <var>node list</var> is
+  not empty:
+
+  <ol>
+    <li>If the first member of <var>node list</var> is a <span>non-list
+    single-line container</span>, <span>set the tag name</span> of the first
+    member of <var>node list</var> to <var>value</var>, then remove the first
+    member from <var>node list</var> and continue this loop from the beginning.
+
+    <li>Let <var>sublist</var> be an empty list of [[nodes]].
+
+    <li>Remove the first member of <var>node list</var> and append it to
+    <var>sublist</var>.
+
+    <li>While <var>node list</var> is not empty, and the first member of
+    <var>node list</var> is the [[nextsibling]] of the last member of
+    <var>sublist</var>, and the first member of <var>node list</var> is not a
+    <span>non-list single-line container</span>, and the last member of
+    <var>sublist</var> is not a [[br]], remove the first member of <var>node
+    list</var> and append it to <var>sublist</var>.
+
+    <li><span>Wrap</span> <var>sublist</var>, with <span>sibling
+    criteria</span> matching nothing and <span>new parent instructions</span>
+    returning the result of running [[createelement|<var>value</var>]] on the
+    [[contextobject]].
+  </ol>
+
+  <li>Otherwise, while <var>node list</var> is not empty:
+
+  <ol>
+    <li>If the first member of <var>node list</var> is a <span>non-list
+    single-line container</span>:
+
+    <ol>
+      <li>Let <var>sublist</var> be the [[children]] of the first member of
+      <var>node list</var>.
+
+      <li>Remove the first member of <var>node list</var> from its [[parent]],
+      <span>preserving its descendants</span>.
+
+      <li>Remove the first member from <var>node list</var>.
+    </ol>
+
+    <li>Otherwise:
+
+    <ol>
+      <li>Let <var>sublist</var> be an empty list of [[nodes]].
+
+      <li>Remove the first member of <var>node list</var> and append it to
+      <var>sublist</var>.
+
+      <li>While <var>node list</var> is not empty, and the first member of
+      <var>node list</var> is the [[nextsibling]] of the last member of
+      <var>sublist</var>, and the first member of <var>node list</var> is not a
+      <span>non-list single-line container</span>, and the last member of
+      <var>sublist</var> is not a [[br]], remove the first member of <var>node
+      list</var> and append it to <var>sublist</var>.
+    </ol>
+
+    <li><span>Wrap</span> <var>sublist</var>, with <span>sibling
+    criteria</span> matching any <span>HTML element</span> with [[localname]]
+    <var>value</var> and no attributes, and <span>new parent
+    instructions</span> returning the result of running
+    [[createelement|<var>value</var>]] on the [[contextobject]].
+  </ol>
+</ol>
+
+
 <h3>Outdenting a node</h3>
 
 <p>To <dfn>outdent</dfn> a [[node]] <var>node</var>:
@@ -3945,132 +4080,7 @@
   <span>non-list single-line container</span> or an <span>allowed child</span>
   of "p".
 
-  <li>For each <var>node</var> in <var>node list</var>, while <var>node</var>
-  is a [[descendant]] of an <span>editable</span> <span>HTML element</span>
-  <span>in the same editing host</span> with [[localname]] "address", "h1",
-  "h2", "h3", "h4", "h5", "h6", "p", or "pre", <span>split the parent</span> of
-  the one-[[node]] list consisting of <var>node</var>.
-
-  <div class=XXX>
-  <p>This is needed so we don't get things like p nested inside address, and
-  instead convert part of the multi-line address into a p.  But div can contain
-  any of these things, so we don't break that apart ever, which is bad.  It
-  means if you have
-
-  <xmp><div>foo<br>bar</div></xmp>
-
-  <p>then formatBlocking "foo" then "bar" as p has different results from doing
-  both at once.  Maybe we should split divs as well, but only if they're the
-  parent of the node we're dealing with?  Or just split divs always, and hope
-  the "in the same editing host" thing handles it?
-  </div>
-
-  <p class=XXX>Do we need to fix disallowed ancestors later, or is this step
-  enough that it's not an issue?
-
-  <!--
-  We have two different behaviors, one for div and p and one for everything
-  else.  The basic difference is that for div and p, we assume that it should
-  be one line per element, while for other elements, we put in multiple lines
-  separated by <br>.  So if you do formatBlock to p on
-
-    <div>foo</div><div>bar</div> or
-    foo<br>bar
-
-  you get
-
-    <p>foo</p><p>bar</p>
-
-  but formatBlock to h1 will get you
-
-    <h1>foo<br>bar</h1>.
-
-  IE9 will just change the elements as they are, so it gives
-  <p>foo</p><p>bar</p> and <h1>foo</h1><h1>bar</h1> for
-  <div>foo</div><div>bar</div>, but <p>foo<br>bar</p> and <h1>foo<br>bar</h1>
-  for foo<br>bar.  This is unreasonable, but the two possible inputs here look
-  identical to the user and might have been produced by identical user input.
-
-  Firefox 5.0a2 will give results like <p>foo</p><p>bar</p> or
-  <h1>foo</h1><h1>bar</h1> no matter what (modulo oddities in its handling of
-  divs).  Opera 11.10 is similar, except it leaves a trailing <br> in the first
-  element.
-
-  Chrome 13 dev will give results like <p>foo<br>bar</p> or <h1>foo<br>bar</h1>
-  no matter what.
-
-  The specced behavior is a compromise between the existing behaviors,
-  predicated on the fact that <h1>foo</h1><h1>bar</h1> almost never makes
-  sense, and <p>foo<br>bar</p> isn't usually what's wanted either.
-  -->
-  <li>If <var>value</var> is "div" or "p", then while <var>node list</var> is
-  not empty:
-
-  <ol>
-    <li>If the first member of <var>node list</var> is a <span>non-list
-    single-line container</span>, <span>set the tag name</span> of the first
-    member of <var>node list</var> to <var>value</var>, then remove the first
-    member from <var>node list</var> and continue this loop from the beginning.
-
-    <li>Let <var>sublist</var> be an empty list of [[nodes]].
-
-    <li>Remove the first member of <var>node list</var> and append it to
-    <var>sublist</var>.
-
-    <li>While <var>node list</var> is not empty, and the first member of
-    <var>node list</var> is the [[nextsibling]] of the last member of
-    <var>sublist</var>, and the first member of <var>node list</var> is not a
-    <span>non-list single-line container</span>, and the last member of
-    <var>sublist</var> is not a [[br]], remove the first member of <var>node
-    list</var> and append it to <var>sublist</var>.
-
-    <li><span>Wrap</span> <var>sublist</var>, with <span>sibling
-    criteria</span> matching nothing and <span>new parent instructions</span>
-    returning the result of running <code data-anolis-spec=domcore
-    title=dom-Document-createElement>createElement(<var>value</var>)</code> on
-    the [[contextobject]].
-  </ol>
-
-  <li>Otherwise, while <var>node list</var> is not empty:
-
-  <ol>
-    <li>If the first member of <var>node list</var> is a <span>non-list
-    single-line container</span>:
-
-    <ol>
-      <li>Let <var>sublist</var> be the [[children]] of the first member of
-      <var>node list</var>.
-
-      <li>Remove the first member of <var>node list</var> from its [[parent]],
-      <span>preserving its descendants</span>.
-
-      <li>Remove the first member from <var>node list</var>.
-    </ol>
-
-    <li>Otherwise:
-
-    <ol>
-      <li>Let <var>sublist</var> be an empty list of [[nodes]].
-
-      <li>Remove the first member of <var>node list</var> and append it to
-      <var>sublist</var>.
-
-      <li>While <var>node list</var> is not empty, and the first member of
-      <var>node list</var> is the [[nextsibling]] of the last member of
-      <var>sublist</var>, and the first member of <var>node list</var> is not a
-      <span>non-list single-line container</span>, and the last member of
-      <var>sublist</var> is not a [[br]], remove the first member of <var>node
-      list</var> and append it to <var>sublist</var>.
-    </ol>
-
-    <li><span>Wrap</span> <var>sublist</var>, with <span>sibling
-    criteria</span> matching any <span>HTML element</span> with [[localname]]
-    <var>value</var> and no attributes, and <span>new parent
-    instructions</span> returning the result of running <code
-    data-anolis-spec=domcore
-    title=dom-Document-createElement>createElement(<var>value</var>)</code> on
-    the [[contextobject]].
-  </ol>
+  <li><span>Block-format</span> <var>node list</var>.
 </ol>