From 3bf72994688ad9292bf37444d80ab5ab1a002748 Mon Sep 17 00:00:00 2001 From: Paweł Sroka Date: Sun, 4 Nov 2012 08:25:28 +0100 Subject: Fixes #1479 - Replaces WP autop with implementation from Steve Clay. --- engine/tests/api/output.php | 64 ++++++++++++++++ .../test_files/output/autop/block-a.exp.norun.html | 6 ++ .../test_files/output/autop/block-a.in.norun.html | 9 +++ .../tests/test_files/output/autop/domdoc_exp.html | 46 +++++++++++ .../tests/test_files/output/autop/domdoc_in.html | 80 +++++++++++++++++++ .../test_files/output/autop/typical-post.exp.html | 84 ++++++++++++++++++++ .../test_files/output/autop/typical-post.in.html | 89 ++++++++++++++++++++++ .../test_files/output/autop/wp-welcome.exp.html | 22 ++++++ .../test_files/output/autop/wp-welcome.in.html | 25 ++++++ .../test_files/output/autop/wpautop-fails.exp.html | 31 ++++++++ .../test_files/output/autop/wpautop-fails.in.html | 41 ++++++++++ .../test_files/output/autop/wysiwyg-test.exp.html | 51 +++++++++++++ .../test_files/output/autop/wysiwyg-test.in.html | 79 +++++++++++++++++++ 13 files changed, 627 insertions(+) create mode 100644 engine/tests/api/output.php create mode 100644 engine/tests/test_files/output/autop/block-a.exp.norun.html create mode 100644 engine/tests/test_files/output/autop/block-a.in.norun.html create mode 100644 engine/tests/test_files/output/autop/domdoc_exp.html create mode 100644 engine/tests/test_files/output/autop/domdoc_in.html create mode 100644 engine/tests/test_files/output/autop/typical-post.exp.html create mode 100644 engine/tests/test_files/output/autop/typical-post.in.html create mode 100644 engine/tests/test_files/output/autop/wp-welcome.exp.html create mode 100644 engine/tests/test_files/output/autop/wp-welcome.in.html create mode 100644 engine/tests/test_files/output/autop/wpautop-fails.exp.html create mode 100644 engine/tests/test_files/output/autop/wpautop-fails.in.html create mode 100644 engine/tests/test_files/output/autop/wysiwyg-test.exp.html create mode 100644 engine/tests/test_files/output/autop/wysiwyg-test.in.html (limited to 'engine/tests') diff --git a/engine/tests/api/output.php b/engine/tests/api/output.php new file mode 100644 index 000000000..eb1a66b29 --- /dev/null +++ b/engine/tests/api/output.php @@ -0,0 +1,64 @@ + + */ +class ElggCoreOutputAutoPTest extends ElggCoreUnitTest { + + /** + * @var ElggAutop + */ + protected $_autop; + + public function setUp() { + $this->_autop = new ElggAutop(); + } + + public function testDomRoundtrip() + { + $d = dir(dirname(__DIR__) . '/test_files/output/autop'); + $in = file_get_contents($d->path . "/domdoc_in.html"); + $exp = file_get_contents($d->path . "/domdoc_exp.html"); + + $doc = new DOMDocument(); + libxml_use_internal_errors(true); + $doc->loadHTML("" + . $in . ''); + $serialized = $doc->saveHTML(); + list(,$out) = explode('', $serialized, 2); + list($out) = explode('', $out, 2); + + $this->assertEqual($exp, $out, "DOMDocument's parsing/serialization roundtrip"); + } + + public function testProcess() + { + $data = $this->provider(); + foreach ($data as $row) { + list($test, $in, $exp) = $row; + $out = $this->_autop->process($in); + $this->assertEqual($exp, $out, "Equality case {$test}"); + } + } + + public function provider() + { + $d = dir(dirname(__DIR__) . '/test_files/output/autop'); + $tests = array(); + while (false !== ($entry = $d->read())) { + if (preg_match('/^([a-z\\-]+)\.in\.html$/i', $entry, $m)) { + $tests[] = $m[1]; + } + } + + $data = array(); + foreach ($tests as $test) { + $data[] = array( + $test, + file_get_contents($d->path . '/' . "{$test}.in.html"), + file_get_contents($d->path . '/' . "{$test}.exp.html"), + ); + } + return $data; + } +} diff --git a/engine/tests/test_files/output/autop/block-a.exp.norun.html b/engine/tests/test_files/output/autop/block-a.exp.norun.html new file mode 100644 index 000000000..addf29dec --- /dev/null +++ b/engine/tests/test_files/output/autop/block-a.exp.norun.html @@ -0,0 +1,6 @@ + +

HTML5 allows A to contain block-level content

+

A treated as block

+

Read more

+
+

A treated as
inline

diff --git a/engine/tests/test_files/output/autop/block-a.in.norun.html b/engine/tests/test_files/output/autop/block-a.in.norun.html new file mode 100644 index 000000000..fc2dac43a --- /dev/null +++ b/engine/tests/test_files/output/autop/block-a.in.norun.html @@ -0,0 +1,9 @@ +HTML5 allows A to contain block-level content + + +

A treated as block

+ + Read more +
+A treated as + inline diff --git a/engine/tests/test_files/output/autop/domdoc_exp.html b/engine/tests/test_files/output/autop/domdoc_exp.html new file mode 100644 index 000000000..8480c1083 --- /dev/null +++ b/engine/tests/test_files/output/autop/domdoc_exp.html @@ -0,0 +1,46 @@ +› +  +Vietnamese - Tiếng Việt + +

h1

+

Paragraph link Bold italic bolditalic 

+

h2

+

Paragraph size1 size2 size4

+

h3

+

Paragraph underline strikethrough color background

+
+

Blockquoted paragraph

+
+

Paragraph following blockquote

+

Paragraph between lists

+
  1. Ordered
  2. +
  3. List
  4. +

Paragraph between lists

+

Paragraph between lists

+ + + + +
Table with
border=0

Paragraph

+
  1. UL list
  2. +
  3. nested +
    • inside a
    • +
    • OL list
    • +
  4. +

Paragraph between tables

+ + + + +
Table with border=1
cellpadding = 5

Paragraph between tables

+ + + + +
Table with
border=2
\ No newline at end of file diff --git a/engine/tests/test_files/output/autop/domdoc_in.html b/engine/tests/test_files/output/autop/domdoc_in.html new file mode 100644 index 000000000..4c465b435 --- /dev/null +++ b/engine/tests/test_files/output/autop/domdoc_in.html @@ -0,0 +1,80 @@ +› +  +Vietnamese - Tiếng Việt + +

h1

+

Paragraph link Bold italic bolditalic 

+

h2

+

Paragraph size1 size2 size4

+

h3

+

Paragraph underline strikethrough color background

+
+

Blockquoted paragraph

+
+

Paragraph following blockquote

+ +

Paragraph between lists

+
    +
  1. Ordered
  2. +
  3. List
  4. +
+

Paragraph between lists

+ +

Paragraph between lists

+ + + + + + + + + + + +
Table with
border=0
+

Paragraph

+
    +
  1. UL list
  2. +
  3. nested +
      +
    • inside a
    • +
    • OL list
    • +
    +
  4. +
+

Paragraph between tables

+ + + + + + + + + + + +
Table with border=1
cellpadding = 5
+

Paragraph between tables

+ + + + + + + + + + + +
Table with
border=2
\ No newline at end of file diff --git a/engine/tests/test_files/output/autop/typical-post.exp.html b/engine/tests/test_files/output/autop/typical-post.exp.html new file mode 100644 index 000000000..f9d75a114 --- /dev/null +++ b/engine/tests/test_files/output/autop/typical-post.exp.html @@ -0,0 +1,84 @@ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+

screenshot of Audition mixing sessionVivamus enim ante, mattis eget imperdiet nec, pharetra vel velit. Sed at euismod nibh. Praesent lacus tellus, posuere et convallis a, mollis et tellus. Suspendisse potenti. Phasellus tincidunt dignissim est eget mattis. Vestibulum lacinia condimentum tellus, non vestibulum erat dapibus quis. Aliquam arcu nibh, viverra adipiscing eleifend quis, pretium vitae ipsum.

+ +

Curabitur turpis ante, congue ac dapibus quis, vehicula ac orci. Nunc luctus neque non massa porta sed pharetra ante accumsan. Nam suscipit risus quis libero convallis viverra. Ut at arcu enim, vel pharetra dolor.

+

Donec at massa ante, sagittis fermentum urna.

+

Mauris volutpat est id massa volutpat lacinia. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In in nisl mauris. In aliquet pretium nisl, vel convallis neque cursus vitae. Curabitur id mauris in urna gravida ornare.

+ +

[caption id="attachment_719" align="alignleft" width="150" caption="Ibanez AGB140 Bass"]Ibanez AGB140 Bass[/caption]

+ +

Aenean aliquet cursus purus sed gravida. Cras auctor euismod justo, ac dictum purus facilisis dignissim. Quisque facilisis porta sem, ac suscipit quam molestie nec. Pellentesque quis hendrerit enim. Vivamus tempor erat diam. Sed eu felis nunc. Cras posuere lorem commodo turpis mollis sagittis. Mauris lobortis nunc felis.

+ +

Maecenas elit lorem, varius sed condimentum ac, cursus et magna. Nam ut massa id augue consectetur porttitor eleifend in nunc. Curabitur cursus varius dictum. Vestibulum vel justo et neque tempus placerat a vel sapien.

+
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim ante, mattis eget imperdiet nec, pharetra vel velit. Sed at euismod nibh. Praesent lacus tellus, posuere et convallis a, mollis et tellus.

+
<?php
+class DataTest extends PHPUnit_Framework_TestCase
+{
+    /**
+     * @dataProvider provider
+     */
+    public function testAdd($a, $b, $c)
+    {
+        $this->assertEquals($c, $a + $b);
+    }
+
+    public function provider()
+    {
+        return array(
+          array(0, 0, 0),
+          array(0, 1, 1),
+          array(1, 0, 1),
+          array(1, 1, 3)
+        );
+    }
+}
+

Nunc luctus neque non massa porta sed pharetra ante accumsan. Nam suscipit risus quis libero convallis viverra. Ut at arcu enim, vel pharetra dolor. Donec at massa ante, sagittis fermentum urna.

+ +

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+

screenshot of Audition mixing sessionVivamus enim ante, mattis eget imperdiet nec, pharetra vel velit. Sed at euismod nibh. Praesent lacus tellus, posuere et convallis a, mollis et tellus. Suspendisse potenti. Phasellus tincidunt dignissim est eget mattis. Vestibulum lacinia condimentum tellus, non vestibulum erat dapibus quis. Aliquam arcu nibh, viverra adipiscing eleifend quis, pretium vitae ipsum.

+ +

Curabitur turpis ante, congue ac dapibus quis, vehicula ac orci. Nunc luctus neque non massa porta sed pharetra ante accumsan. Nam suscipit risus quis libero convallis viverra. Ut at arcu enim, vel pharetra dolor.

+

Donec at massa ante, sagittis fermentum urna.

+

Mauris volutpat est id massa volutpat lacinia. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In in nisl mauris. In aliquet pretium nisl, vel convallis neque cursus vitae. Curabitur id mauris in urna gravida ornare.

+ +

[caption id="attachment_719" align="alignleft" width="150" caption="Ibanez AGB140 Bass"]Ibanez AGB140 Bass[/caption]

+ +

Aenean aliquet cursus purus sed gravida. Cras auctor euismod justo, ac dictum purus facilisis dignissim. Quisque facilisis porta sem, ac suscipit quam molestie nec. Pellentesque quis hendrerit enim. Vivamus tempor erat diam. Sed eu felis nunc. Cras posuere lorem commodo turpis mollis sagittis. Mauris lobortis nunc felis.

+ +

Maecenas elit lorem, varius sed condimentum ac, cursus et magna. Nam ut massa id augue consectetur porttitor eleifend in nunc. Curabitur cursus varius dictum. Vestibulum vel justo et neque tempus placerat a vel sapien.

+
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim ante, mattis eget imperdiet nec, pharetra vel velit. Sed at euismod nibh. Praesent lacus tellus, posuere et convallis a, mollis et tellus.

+
<?php
+class DataTest extends PHPUnit_Framework_TestCase
+{
+    /**
+     * @dataProvider provider
+     */
+    public function testAdd($a, $b, $c)
+    {
+        $this->assertEquals($c, $a + $b);
+    }
+
+    public function provider()
+    {
+        return array(
+          array(0, 0, 0),
+          array(0, 1, 1),
+          array(1, 0, 1),
+          array(1, 1, 3)
+        );
+    }
+}
+

Nunc luctus neque non massa porta sed pharetra ante accumsan. Nam suscipit risus quis libero convallis viverra. Ut at arcu enim, vel pharetra dolor. Donec at massa ante, sagittis fermentum urna.

+ +

diff --git a/engine/tests/test_files/output/autop/typical-post.in.html b/engine/tests/test_files/output/autop/typical-post.in.html new file mode 100644 index 000000000..6e4984cc4 --- /dev/null +++ b/engine/tests/test_files/output/autop/typical-post.in.html @@ -0,0 +1,89 @@ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+screenshot of Audition mixing sessionVivamus enim ante, mattis eget imperdiet nec, pharetra vel velit. Sed at euismod nibh. Praesent lacus tellus, posuere et convallis a, mollis et tellus. Suspendisse potenti. Phasellus tincidunt dignissim est eget mattis. Vestibulum lacinia condimentum tellus, non vestibulum erat dapibus quis. Aliquam arcu nibh, viverra adipiscing eleifend quis, pretium vitae ipsum. + +Curabitur turpis ante, congue ac dapibus quis, vehicula ac orci. Nunc luctus neque non massa porta sed pharetra ante accumsan. Nam suscipit risus quis libero convallis viverra. Ut at arcu enim, vel pharetra dolor. +

Donec at massa ante, sagittis fermentum urna.

+
Mauris volutpat est id massa volutpat lacinia. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In in nisl mauris. In aliquet pretium nisl, vel convallis neque cursus vitae. Curabitur id mauris in urna gravida ornare. + +[caption id="attachment_719" align="alignleft" width="150" caption="Ibanez AGB140 Bass"]Ibanez AGB140 Bass[/caption] + +Aenean aliquet cursus purus sed gravida. Cras auctor euismod justo, ac dictum purus facilisis dignissim. Quisque facilisis porta sem, ac suscipit quam molestie nec. Pellentesque quis hendrerit enim. Vivamus tempor erat diam. Sed eu felis nunc. Cras posuere lorem commodo turpis mollis sagittis. Mauris lobortis nunc felis. + +Maecenas elit lorem, varius sed condimentum ac, cursus et magna. Nam ut massa id augue consectetur porttitor eleifend in nunc. Curabitur cursus varius dictum. Vestibulum vel justo et neque tempus placerat a vel sapien.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim ante, mattis eget imperdiet nec, pharetra vel velit. Sed at euismod nibh. Praesent lacus tellus, posuere et convallis a, mollis et tellus. + +
<?php
+class DataTest extends PHPUnit_Framework_TestCase
+{
+    /**
+     * @dataProvider provider
+     */
+    public function testAdd($a, $b, $c)
+    {
+        $this->assertEquals($c, $a + $b);
+    }
+
+    public function provider()
+    {
+        return array(
+          array(0, 0, 0),
+          array(0, 1, 1),
+          array(1, 0, 1),
+          array(1, 1, 3)
+        );
+    }
+}
+ +Nunc luctus neque non massa porta sed pharetra ante accumsan. Nam suscipit risus quis libero convallis viverra. Ut at arcu enim, vel pharetra dolor. Donec at massa ante, sagittis fermentum urna. + + + +

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+screenshot of Audition mixing sessionVivamus enim ante, mattis eget imperdiet nec, pharetra vel velit. Sed at euismod nibh. Praesent lacus tellus, posuere et convallis a, mollis et tellus. Suspendisse potenti. Phasellus tincidunt dignissim est eget mattis. Vestibulum lacinia condimentum tellus, non vestibulum erat dapibus quis. Aliquam arcu nibh, viverra adipiscing eleifend quis, pretium vitae ipsum. + +Curabitur turpis ante, congue ac dapibus quis, vehicula ac orci. Nunc luctus neque non massa porta sed pharetra ante accumsan. Nam suscipit risus quis libero convallis viverra. Ut at arcu enim, vel pharetra dolor. +

Donec at massa ante, sagittis fermentum urna.

+
Mauris volutpat est id massa volutpat lacinia. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In in nisl mauris. In aliquet pretium nisl, vel convallis neque cursus vitae. Curabitur id mauris in urna gravida ornare. + +[caption id="attachment_719" align="alignleft" width="150" caption="Ibanez AGB140 Bass"]Ibanez AGB140 Bass[/caption] + +Aenean aliquet cursus purus sed gravida. Cras auctor euismod justo, ac dictum purus facilisis dignissim. Quisque facilisis porta sem, ac suscipit quam molestie nec. Pellentesque quis hendrerit enim. Vivamus tempor erat diam. Sed eu felis nunc. Cras posuere lorem commodo turpis mollis sagittis. Mauris lobortis nunc felis. + +Maecenas elit lorem, varius sed condimentum ac, cursus et magna. Nam ut massa id augue consectetur porttitor eleifend in nunc. Curabitur cursus varius dictum. Vestibulum vel justo et neque tempus placerat a vel sapien.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim ante, mattis eget imperdiet nec, pharetra vel velit. Sed at euismod nibh. Praesent lacus tellus, posuere et convallis a, mollis et tellus. + +
<?php
+class DataTest extends PHPUnit_Framework_TestCase
+{
+    /**
+     * @dataProvider provider
+     */
+    public function testAdd($a, $b, $c)
+    {
+        $this->assertEquals($c, $a + $b);
+    }
+
+    public function provider()
+    {
+        return array(
+          array(0, 0, 0),
+          array(0, 1, 1),
+          array(1, 0, 1),
+          array(1, 1, 3)
+        );
+    }
+}
+ +Nunc luctus neque non massa porta sed pharetra ante accumsan. Nam suscipit risus quis libero convallis viverra. Ut at arcu enim, vel pharetra dolor. Donec at massa ante, sagittis fermentum urna. + + \ No newline at end of file diff --git a/engine/tests/test_files/output/autop/wp-welcome.exp.html b/engine/tests/test_files/output/autop/wp-welcome.exp.html new file mode 100644 index 000000000..2f612e3dd --- /dev/null +++ b/engine/tests/test_files/output/autop/wp-welcome.exp.html @@ -0,0 +1,22 @@ + +

Welcome to WordPress! This post contains important information. After you read it, you can make it private to hide it from visitors but still have the information handy for future reference.

+ +

First things first:

+ +

As a subscriber, you will receive an email every time an update is available (and only then). This will make it easier to keep your site up to date, and secure from evildoers.
When a new version is released, log in to the Dashboard and follow the instructions.
Upgrading is a couple of clicks!

+ +

Then you can start enjoying the WordPress experience:

+ +

To keep this post for reference, click to edit it, go to the Publish box and change its Visibility from Public to Private.

+ +

Thank you for selecting WordPress. We wish you happy publishing!

+ +

PS. Not yet subscribed for update notifications? Do it now!

diff --git a/engine/tests/test_files/output/autop/wp-welcome.in.html b/engine/tests/test_files/output/autop/wp-welcome.in.html new file mode 100644 index 000000000..338ede73f --- /dev/null +++ b/engine/tests/test_files/output/autop/wp-welcome.in.html @@ -0,0 +1,25 @@ +Welcome to WordPress! This post contains important information. After you read it, you can make it private to hide it from visitors but still have the information handy for future reference. + +First things first: + +As a subscriber, you will receive an email every time an update is available (and only then). This will make it easier to keep your site up to date, and secure from evildoers. +When a new version is released, log in to the Dashboard and follow the instructions. +Upgrading is a couple of clicks! + +Then you can start enjoying the WordPress experience: + +To keep this post for reference, click to edit it, go to the Publish box and change its Visibility from Public to Private. + +Thank you for selecting WordPress. We wish you happy publishing! + +PS. Not yet subscribed for update notifications? Do it now! diff --git a/engine/tests/test_files/output/autop/wpautop-fails.exp.html b/engine/tests/test_files/output/autop/wpautop-fails.exp.html new file mode 100644 index 000000000..d018db4ff --- /dev/null +++ b/engine/tests/test_files/output/autop/wpautop-fails.exp.html @@ -0,0 +1,31 @@ + +

paragraph

+ +

paragraph

+
+

paragraph

+
+

line

+
+

paragraph

+ +

paragraph
line
line

+
Honor
+this whitespace
+
+

paragraph

+ +

paragraph

+
term
paragraph + + + +paragraph
+

Hello

World

+

Paragraph

Line
\ No newline at end of file diff --git a/engine/tests/test_files/output/autop/wpautop-fails.in.html b/engine/tests/test_files/output/autop/wpautop-fails.in.html new file mode 100644 index 000000000..9aa24be59 --- /dev/null +++ b/engine/tests/test_files/output/autop/wpautop-fails.in.html @@ -0,0 +1,41 @@ + +paragraph + +paragraph
+ paragraph +
+ line +
+ +paragraph + +paragraph +line
+ line +
Honor
+this whitespace
+
+paragraph + +paragraph +
term
paragraph + + + +paragraph
+
+ +Hello + +World + +

Paragraph

+ +
Line
\ No newline at end of file diff --git a/engine/tests/test_files/output/autop/wysiwyg-test.exp.html b/engine/tests/test_files/output/autop/wysiwyg-test.exp.html new file mode 100644 index 000000000..1f23d6154 --- /dev/null +++ b/engine/tests/test_files/output/autop/wysiwyg-test.exp.html @@ -0,0 +1,51 @@ + +

&nbps;

+

h1

+

Paragraph link Bold italic bolditalic 

+

h2

+

Paragraph size1 size2 size4

+

h3

+

Paragraph underline strikethrough color background

+
+

Blockquoted paragraph

+
+

Paragraph following blockquote

+ +

Paragraph between lists

+
  1. Ordered
  2. +
  3. List
  4. +
+

Paragraph between lists

+ +

Paragraph between lists

+ + + + +
Table with
border=0
+

Paragraph

+
  1. UL list
  2. +
  3. nested +
    • inside a
    • +
    • OL list
    • +
  4. +
+

Paragraph between tables

+ + + + +
Table with border=1
cellpadding = 5
+

Paragraph between tables

+ + + + +
Table with
border=2
\ No newline at end of file diff --git a/engine/tests/test_files/output/autop/wysiwyg-test.in.html b/engine/tests/test_files/output/autop/wysiwyg-test.in.html new file mode 100644 index 000000000..733b0e2ec --- /dev/null +++ b/engine/tests/test_files/output/autop/wysiwyg-test.in.html @@ -0,0 +1,79 @@ +&nbps; +≴ +

h1

+Paragraph link Bold italic bolditalic  +

h2

+Paragraph size1 size2 size4 +

h3

+Paragraph underline strikethrough color background +
Blockquoted paragraph
+Paragraph following blockquote + +Paragraph between lists +
    +
  1. Ordered
  2. +
  3. List
  4. +
+Paragraph between lists + +Paragraph between lists + + + + + + + + + + + + + +
Table with
border=0
+Paragraph +
    +
  1. UL list
  2. +
  3. nested +
      +
    • inside a
    • +
    • OL list
    • +
    +
  4. +
+Paragraph between tables + + + + + + + + + + + +
Table with border=1
cellpadding = 5
+Paragraph between tables + + + + + + + + + + + +
Table with
border=2
\ No newline at end of file -- cgit v1.2.3