Skip to content

Commit 9352599

Browse files
jschroed91adamCaxy
authored andcommitted
Fix issues with spaces being removed in isolated diff tags (#41)
* Remove trim calls in constructor * Update tests for fix on trim calls
1 parent 7612aee commit 9352599

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

lib/Caxy/HtmlDiff/AbstractDiff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCas
8080
$this->config->setGroupDiffs($groupDiffs);
8181
}
8282

83-
$this->oldText = $this->purifyHtml(trim($oldText));
84-
$this->newText = $this->purifyHtml(trim($newText));
83+
$this->oldText = $this->purifyHtml($oldText);
84+
$this->newText = $this->purifyHtml($newText);
8585
$this->content = '';
8686
}
8787

tests/fixtures/HtmlDiff/first-and-last.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
</newText>
3636

3737
<expected>
38-
<ol class="diff-list"><li class="normal"><del class="diffmod">Etiam feugiat lorem</del><ins class="diffmod">Suspendisse</ins> non <del class="diffmod">metus</del><ins class="diffmod">nisl sit amet velit hendrerit rutrum</ins>. <del class="diffmod">Nullam accumsan lorem in</del><ins class="diffmod">Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In</ins> dui<ins class="diffins"> magna, posuere eget, vestibulum et, tempor auctor, justo</ins>.</li><li class="normal"><del class="diffmod">Praesent ac sem eget est egestas volutpat. Nulla neque dolor</del><ins class="diffmod">Donec pede justo</ins>, <del class="diffmod">sagittis</del><ins class="diffmod">fringilla vel, aliquet nec, vulputate</ins> eget, <del class="diffmod">iaculis quis, molestie non, velit</del><ins class="diffmod">arcu</ins>.<del class="diffdel"> Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Aenean massa.</del></li><li class="normal"><del class="diffmod">Vestibulum suscipit nulla quis orci</del><ins class="diffmod">Duis lobortis massa imperdiet quam</ins>. <del class="diffmod">Integer ante arcu</del><ins class="diffmod">Donec sodales sagittis magna. Nam ipsum risus</ins>, <del class="diffmod">accumsan a</del><ins class="diffmod">rutrum vitae</ins>, <del class="diffmod">consectetuer eget</del><ins class="diffmod">vestibulum eu</ins>, <del class="diffmod">posuere ut</del><ins class="diffmod">molestie vel</ins>, <del class="diffmod">mauris</del><ins class="diffmod">lacus</ins>. <del class="diffmod">Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos</del><ins class="diffmod">Suspendisse eu ligula</ins>.<ins class="diffins"> Morbi nec metus.</ins></li><li class="removed"><del> Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. </del></li></ol>
39-
</expected>
38+
<ol class="diff-list"><li class="normal"><del class="diffmod"> Etiam feugiat lorem</del><ins class="diffmod"> Suspendisse</ins> non <del class="diffmod">metus</del><ins class="diffmod">nisl sit amet velit hendrerit rutrum</ins>. <del class="diffmod">Nullam accumsan lorem in</del><ins class="diffmod">Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In</ins> dui<ins class="diffins"> magna, posuere eget, vestibulum et, tempor auctor, justo</ins>. </li><li class="normal"><del class="diffmod"> Praesent ac sem eget est egestas volutpat. Nulla neque dolor</del><ins class="diffmod"> Donec pede justo</ins>, <del class="diffmod">sagittis</del><ins class="diffmod">fringilla vel, aliquet nec, vulputate</ins> eget, <del class="diffmod">iaculis quis, molestie non, velit</del><ins class="diffmod">arcu</ins>. <del class="diffdel">Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Aenean massa. </del></li><li class="normal"><del class="diffmod"> Vestibulum suscipit nulla quis orci</del><ins class="diffmod"> Duis lobortis massa imperdiet quam</ins>. <del class="diffmod">Integer ante arcu</del><ins class="diffmod">Donec sodales sagittis magna. Nam ipsum risus</ins>, <del class="diffmod">accumsan a</del><ins class="diffmod">rutrum vitae</ins>, <del class="diffmod">consectetuer eget</del><ins class="diffmod">vestibulum eu</ins>, <del class="diffmod">posuere ut</del><ins class="diffmod">molestie vel</ins>, <del class="diffmod">mauris</del><ins class="diffmod">lacus</ins>. <del class="diffmod">Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos</del><ins class="diffmod">Suspendisse eu ligula</ins>. <ins class="diffins">Morbi nec metus. </ins></li><li class="removed"><del> Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. </del></li></ol>
39+
</expected>

tests/fixtures/HtmlDiff/override-4.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
</newText>
2525

2626
<expected>
27-
<em>Corridors</em> shall be fire-resistance rated in accordance with Table 1020.1<ins class="diffins"> and where applicable in Section 1020.1.1</ins>. The <em>corridor</em> walls required to be fire-resistance rated shall comply with Section 708 for <em>fire partitions</em>.<br /><br / class="diffmod"><del class="diffdel">In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:</del><br / class="diffmod"><br /><ol><li><del class="diffdel">Assigned a Seismic Design Category C or D in Table 1613.3.5(1).</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Located in a flood hazard area established in accordance with Section 1612.3.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Located in a </del><em class="diffmod"><del class="diffdel">hurricane-prone regions</del></em><del class="diffdel">.</del></li><del class="diffdel"> </del></ol><ul class="exception" class="diff-list"><li class="normal new"><ins><strong>Exceptions:</strong></ins></li><li class="normal"><strong class="diffmod"><del class="diffdel">Exceptions:</del></strong><ol class="diff-list"><li class="normal">A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required <em>means of egress</em> doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.</li><li class="normal">A <em>fire-resistance rating</em> is not required for <em>corridors</em> contained within a <em>dwelling unit</em> or <em>sleeping unit</em> in an occupancy in Groups I-1 and R.</li><li class="normal">A <em>fire-resistance rating</em> is not required for <em>corridors</em> in <em>open parking garages</em>.</li><li class="normal">A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group B that is a space requiring only a single <em>means of egress</em> complying with Section 1006.2.</li><li class="normal"><em>Corridors</em> adjacent to the <em>exterior walls</em> of buildings shall be permitted to have unprotected openings on unrated <em>exterior walls</em> where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.</li></ol></li></ul>
27+
<em>Corridors</em> shall be fire-resistance rated in accordance with Table 1020.1<ins class="diffins"> and where applicable in Section 1020.1.1</ins>. The <em>corridor</em> walls required to be fire-resistance rated shall comply with Section 708 for <em>fire partitions</em>.<br /><br / class="diffmod"><del class="diffdel">In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:</del><br / class="diffmod"><br /><ol><li><del class="diffdel">Assigned a Seismic Design Category C or D in Table 1613.3.5(1).</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Located in a flood hazard area established in accordance with Section 1612.3.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Located in a </del><em class="diffmod"><del class="diffdel">hurricane-prone regions</del></em><del class="diffdel">.</del></li><del class="diffdel"> </del></ol><ul class="exception" class="diff-list"><li class="normal new"><ins><strong>Exceptions:</strong></ins></li><li class="normal"><strong class="diffmod"><del class="diffmod">Exceptions:</del></strong><ins class="diffmod"> </ins><ol class="diff-list"><li class="normal">A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required <em>means of egress</em> doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.</li><li class="normal">A <em>fire-resistance rating</em> is not required for <em>corridors</em> contained within a <em>dwelling unit</em> or <em>sleeping unit</em> in an occupancy in Groups I-1 and R.</li><li class="normal">A <em>fire-resistance rating</em> is not required for <em>corridors</em> in <em>open parking garages</em>.</li><li class="normal">A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group B that is a space requiring only a single <em>means of egress</em> complying with Section 1006.2.</li><li class="normal"><em>Corridors</em> adjacent to the <em>exterior walls</em> of buildings shall be permitted to have unprotected openings on unrated <em>exterior walls</em> where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.</li></ol></li></ul>
2828
</expected>

tests/fixtures/HtmlDiff/override-5.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
</newText>
2828

2929
<expected>
30-
<p>In addition to the <em>means of egress</em> required by this chapter, <del class="diffmod">provisions </del><em class="diffmod"><ins class="diffmod">emergency escape and rescue openings </ins></em>shall be <del class="diffmod">made for </del><em class="diffmod"><del class="diffmod">emergency escape and rescue openings</del></em><ins class="diffmod">provided</ins> in<ins class="diffins"> the following occupancies:</ins></p><ins class="diffins"> </ins><div style="padding-left:30px;" class="diffmod"><ins class="diffins">1.</ins> Group R<ins class="diffins">-1 and R-2</ins> occupancies.<del class="diffmod"> </del></div><ins class="diffmod"> </ins><div style="padding-left:30px;" class="diffmod"><ins class="diffmod">2. Group R-1 and R-2 occupancies located on stories with one exit or access to one exit where permitted by Tables 1006.3.2(1) and 1006.3.2(2). </ins></div><ins class="diffmod"> </ins><div style="padding-left:30px;" class="diffmod"><ins class="diffmod">3. Group R-3 occupancies.</ins></div><ins class="diffmod"> </ins><p class="diffmod"><br /><em>Basements</em> and sleeping rooms below the fourth story above <em>grade plane</em> shall have at least one exterior <em>emergency escape and rescue opening</em> in accordance with this section. Where <em>basements</em> contain one or more sleeping rooms, <em>emergency escape and rescue openings</em> shall be required in each sleeping room, but shall not be required in adjoining areas of the <em>basement</em>. Such openings shall open directly into a <em>public way</em> or to a <em>yard</em>or<em>court</em> that opens to a <em>public way</em>.</p> <ul class="exception" class="diff-list"><li class="normal"><strong>Exceptions:</strong><br / class="diffmod"><ol class="diff-list"><li class="normal"><em><del class="diffmod">Groups R-1</del><ins class="diffmod">Emergency escape</ins> and <del class="diffmod">R-2 occupancies are not required to provide emergency and escape openings where they comply with all of the following:</del><ins class="diffmod">rescue opening</ins></em><ol class="diffmod"><li><em><del class="diffmod">Each story has access to two or more means of egress.</del><br / class="diffmod"></em></li><del class="diffmod"> </del><li class="diffmod"><em><del class="diffmod">The building is constructed of Type I, Type II, Type IIIA or Type IV construction.</del></em></li><del class="diffmod"> </del><li class="diffmod"><em><del class="diffmod">The building is equipped throughout with an approved automatic sprinkler system in accordance with Sections 903.3.1.1 or 903.3.3.2.</del></em></li><del class="diffmod"> </del></ol><ins class="diffmod"> are not required from Group R-1 and R-2 occupancies where each story has access to at least two exits or access to exits and the building is equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1.</ins></li><li class="removed"><del><em>The emergency escape and rescue opening is permitted to open onto a balcony within an atrium in accordance with the requirements of Section 404, provided the balcony provides access to an exit and the dwelling unit or sleeping unit has a means of egress that is not open to the atrium.</em></del></li><li class="replacement"><em>Basements</em> with a ceiling height of less than 80 inches (2032 mm) shall not be required to have <em>emergency escape and rescue openings</em>.</li><li class="normal"><em>Emergency escape and rescue openings</em> are not required from <em>basements</em> or sleeping rooms that have an <em>exit</em> door or <em>exit access</em> door that opens directly into a <em>public way</em> or to a <em>yard</em>, <em>court</em> or exterior exit balcony that opens to a <em>public way</em>.</li><li class="normal"><em>Basements</em> without <em>habitable spaces</em> and having not more than 200 square feet (18.6 m<sup>2</sup>) in floor area shall not be required to have <em>emergency escape and rescue openings</em>.</li></ol></li></ul>
30+
<p>In addition to the <em>means of egress</em> required by this chapter, <del class="diffmod">provisions </del><em class="diffmod"><ins class="diffmod">emergency escape and rescue openings </ins></em>shall be <del class="diffmod">made for </del><em class="diffmod"><del class="diffmod">emergency escape and rescue openings</del></em><ins class="diffmod">provided</ins> in<ins class="diffins"> the following occupancies:</ins></p><ins class="diffins"> </ins><div style="padding-left:30px;" class="diffmod"><ins class="diffins">1.</ins> Group R<ins class="diffins">-1 and R-2</ins> occupancies.<del class="diffmod"> </del></div><ins class="diffmod"> </ins><div style="padding-left:30px;" class="diffmod"><ins class="diffmod">2. Group R-1 and R-2 occupancies located on stories with one exit or access to one exit where permitted by Tables 1006.3.2(1) and 1006.3.2(2). </ins></div><ins class="diffmod"> </ins><div style="padding-left:30px;" class="diffmod"><ins class="diffmod">3. Group R-3 occupancies.</ins></div><ins class="diffmod"> </ins><p class="diffmod"><br /><em>Basements</em> and sleeping rooms below the fourth story above <em>grade plane</em> shall have at least one exterior <em>emergency escape and rescue opening</em> in accordance with this section. Where <em>basements</em> contain one or more sleeping rooms, <em>emergency escape and rescue openings</em> shall be required in each sleeping room, but shall not be required in adjoining areas of the <em>basement</em>. Such openings shall open directly into a <em>public way</em> or to a <em>yard </em>or<em> court</em> that opens to a <em>public way</em>.</p> <ul class="exception" class="diff-list"><li class="normal"><strong>Exceptions:</strong><br / class="diffmod"><ol class="diff-list"><li class="normal"><em><del class="diffmod">Groups R-1</del><ins class="diffmod">Emergency escape</ins> and <del class="diffmod">R-2 occupancies are not required to provide emergency and escape openings where they comply with all of the following:</del><ins class="diffmod">rescue opening</ins></em><ol class="diffmod"><li><em><del class="diffmod">Each story has access to two or more means of egress.</del><br / class="diffmod"></em></li><del class="diffmod"> </del><li class="diffmod"><em><del class="diffmod">The building is constructed of Type I, Type II, Type IIIA or Type IV construction.</del></em></li><del class="diffmod"> </del><li class="diffmod"><em><del class="diffmod">The building is equipped throughout with an approved automatic sprinkler system in accordance with Sections 903.3.1.1 or 903.3.3.2.</del></em></li><del class="diffmod"> </del></ol><ins class="diffmod"> are not required from Group R-1 and R-2 occupancies where each story has access to at least two exits or access to exits and the building is equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1.</ins></li><li class="removed"><del><em>The emergency escape and rescue opening is permitted to open onto a balcony within an atrium in accordance with the requirements of Section 404, provided the balcony provides access to an exit and the dwelling unit or sleeping unit has a means of egress that is not open to the atrium.</em></del></li><li class="replacement"><em>Basements</em> with a ceiling height of less than 80 inches (2032 mm) shall not be required to have <em>emergency escape and rescue openings</em>.</li><li class="normal"><em>Emergency escape and rescue openings</em> are not required from <em>basements</em> or sleeping rooms that have an <em>exit</em> door or <em>exit access</em> door that opens directly into a <em>public way</em> or to a <em>yard</em>, <em>court</em> or exterior exit balcony that opens to a <em>public way</em>.</li><li class="normal"><em>Basements</em> without <em>habitable spaces</em> and having not more than 200 square feet (18.6 m<sup>2</sup>) in floor area shall not be required to have <em>emergency escape and rescue openings</em>.</li></ol></li></ul>
3131
</expected>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<oldText>
2+
Testing <i>italic text </i>with intentional space and a (word) with parenthesis.
3+
</oldText>
4+
<newText>
5+
Testing <i>italic text </i>with a space and a (word) with parenthesis.
6+
</newText>
7+
<expected>
8+
Testing <i>italic text </i>with <del class="diffmod">intentional</del><ins class="diffmod">a</ins> space and a (word) with parenthesis.
9+
</expected>

0 commit comments

Comments
 (0)