From 3c277a17010efdcd22088c4f6282375517a2561c Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Tue, 17 Mar 2015 12:01:45 -0700 Subject: [PATCH] Bug 1127778 - fix paragraph reordering and add a test for it. --- Readability.js | 4 +-- .../reordering-paragraphs/expected.html | 27 +++++++++++++++++++ .../reordering-paragraphs/source.html | 9 +++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 test/test-pages/reordering-paragraphs/expected.html create mode 100644 test/test-pages/reordering-paragraphs/source.html diff --git a/Readability.js b/Readability.js index d1e4cbe..03d3b30 100644 --- a/Readability.js +++ b/Readability.js @@ -679,8 +679,8 @@ Readability.prototype = { div.id = "readability-page-1"; div.className = "page"; var children = articleContent.childNodes; - for (var i = 0; i < children.length; ++i) { - div.appendChild(children[i]); + while (children.length) { + div.appendChild(children[0]); } articleContent.appendChild(div); } diff --git a/test/test-pages/reordering-paragraphs/expected.html b/test/test-pages/reordering-paragraphs/expected.html new file mode 100644 index 0000000..d5fafab --- /dev/null +++ b/test/test-pages/reordering-paragraphs/expected.html @@ -0,0 +1,27 @@ +
+

Regarding item# 11111, under sufficiently extreme conditions, quarks may + become deconfined and exist as free particles. In the course of asymptotic + freedom, the strong interaction becomes weaker at higher temperatures. + Eventually, color confinement would be lost and an extremely hot plasma + of freely moving quarks and gluons would be formed. This theoretical phase + of matter is called quark-gluon plasma.[81] The exact conditions needed + to give rise to this state are unknown and have been the subject of a great + deal of speculation and experimentation.

+

Regarding item# 22222, under sufficiently extreme conditions, quarks may + become deconfined and exist as free particles. In the course of asymptotic + freedom, the strong interaction becomes weaker at higher temperatures. + Eventually, color confinement would be lost and an extremely hot plasma + of freely moving quarks and gluons would be formed. This theoretical phase + of matter is called quark-gluon plasma.[81] The exact conditions needed + to give rise to this state are unknown and have been the subject of a great + deal of speculation and experimentation.

+

Regarding item# 33333, under sufficiently extreme conditions, quarks may + become deconfined and exist as free particles. In the course of asymptotic + freedom, the strong interaction becomes weaker at higher temperatures. + Eventually, color confinement would be lost and an extremely hot plasma + of freely moving quarks and gluons would be formed. This theoretical phase + of matter is called quark-gluon plasma.[81] The exact conditions needed + to give rise to this state are unknown and have been the subject of a great + deal of speculation and experimentation.

+
diff --git a/test/test-pages/reordering-paragraphs/source.html b/test/test-pages/reordering-paragraphs/source.html new file mode 100644 index 0000000..849fd21 --- /dev/null +++ b/test/test-pages/reordering-paragraphs/source.html @@ -0,0 +1,9 @@ + + +
+

Regarding item# 11111, under sufficiently extreme conditions, quarks may become deconfined and exist as free particles. In the course of asymptotic freedom, the strong interaction becomes weaker at higher temperatures. Eventually, color confinement would be lost and an extremely hot plasma of freely moving quarks and gluons would be formed. This theoretical phase of matter is called quark-gluon plasma.[81] The exact conditions needed to give rise to this state are unknown and have been the subject of a great deal of speculation and experimentation.

+

Regarding item# 22222, under sufficiently extreme conditions, quarks may become deconfined and exist as free particles. In the course of asymptotic freedom, the strong interaction becomes weaker at higher temperatures. Eventually, color confinement would be lost and an extremely hot plasma of freely moving quarks and gluons would be formed. This theoretical phase of matter is called quark-gluon plasma.[81] The exact conditions needed to give rise to this state are unknown and have been the subject of a great deal of speculation and experimentation.

+

Regarding item# 33333, under sufficiently extreme conditions, quarks may become deconfined and exist as free particles. In the course of asymptotic freedom, the strong interaction becomes weaker at higher temperatures. Eventually, color confinement would be lost and an extremely hot plasma of freely moving quarks and gluons would be formed. This theoretical phase of matter is called quark-gluon plasma.[81] The exact conditions needed to give rise to this state are unknown and have been the subject of a great deal of speculation and experimentation.

+
+ +