Skip to content

Commit

Permalink
refactor(renderer): discard quote replacement in HTML
Browse files Browse the repository at this point in the history
No need to replace ' and " with &bytesparadise#39; and &bytesparadise#34;

Fixes bytesparadise#565

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon committed May 23, 2020
1 parent b17f6e1 commit a02b80d
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 46 deletions.
6 changes: 3 additions & 3 deletions libasciidoc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Free use of this software is granted under the terms of the MIT License.`

expectedContent := `<h2 id="_name">Name</h2>
<div class="sectionbody">
<p>eve - analyzes an image to determine if it&#39;s a picture of a life form</p>
<p>eve - analyzes an image to determine if it's a picture of a life form</p>
</div>
<div class="sect1">
<h2 id="_synopsis">Synopsis</h2>
Expand Down Expand Up @@ -355,7 +355,7 @@ Free use of this software is granted under the terms of the MIT License.`
<h1>eve(1) Manual Page</h1>
<h2 id="_name">Name</h2>
<div class="sectionbody">
<p>eve - analyzes an image to determine if it&#39;s a picture of a life form</p>
<p>eve - analyzes an image to determine if it's a picture of a life form</p>
</div>
</div>
<div id="content">
Expand Down Expand Up @@ -434,7 +434,7 @@ Free use of this software is granted under the terms of the MIT License.`
<h2 id="_foo">Foo</h2>
<div class="sectionbody">
<div class="paragraph">
<p>eve - analyzes an image to determine if it&#39;s a picture of a life form</p>
<p>eve - analyzes an image to determine if it's a picture of a life form</p>
</div>
</div>
</div>
Expand Down
26 changes: 13 additions & 13 deletions pkg/renderer/html5/delimited_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ end
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="highlight"><code>require &#39;sinatra&#39;
<pre class="highlight"><code>require 'sinatra'
get &#39;/hi&#39; do
&#34;Hello World!&#34;
get '/hi' do
"Hello World!"
end</code></pre>
</div>
</div>`
Expand All @@ -154,10 +154,10 @@ end
expected := `<div class="listingblock">
<div class="title">Source block title</div>
<div class="content">
<pre class="highlight"><code class="language-ruby" data-lang="ruby">require &#39;sinatra&#39;
<pre class="highlight"><code class="language-ruby" data-lang="ruby">require 'sinatra'
get &#39;/hi&#39; do
&#34;Hello World!&#34;
get '/hi' do
"Hello World!"
end</code></pre>
</div>
</div>`
Expand All @@ -178,10 +178,10 @@ end
expected := `<div class="listingblock">
<div class="title">Source block title</div>
<div class="content">
<pre class="highlight"><code class="language-ruby" data-lang="ruby">require &#39;sinatra&#39;
<pre class="highlight"><code class="language-ruby" data-lang="ruby">require 'sinatra'
get &#39;/hi&#39; do
&#34;Hello World!&#34;
get '/hi' do
"Hello World!"
end</code></pre>
</div>
</div>`
Expand All @@ -202,10 +202,10 @@ end
expected := `<div id="id-for-source-block" class="listingblock">
<div class="title">app.rb</div>
<div class="content">
<pre class="highlight"><code class="language-ruby" data-lang="ruby">require &#39;sinatra&#39;
<pre class="highlight"><code class="language-ruby" data-lang="ruby">require 'sinatra'
get &#39;/hi&#39; do
&#34;Hello World!&#34;
get '/hi' do
"Hello World!"
end</code></pre>
</div>
</div>`
Expand Down Expand Up @@ -297,7 +297,7 @@ and "more" content
<p><strong>bold content</strong></p>
</div>
<div class="paragraph">
<p>and &#34;more&#34; content</p>
<p>and "more" content</p>
</div>
</div>
</div>`
Expand Down
36 changes: 18 additions & 18 deletions pkg/renderer/html5/file_inclusion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ include::../../../test/includes/hello_world.go.txt[]`
<p>package includes</p>
</div>
<div class="paragraph">
<p>import &#34;fmt&#34;</p>
<p>import "fmt"</p>
</div>
<div class="paragraph">
<p>func helloworld() {
fmt.Println(&#34;hello, world!&#34;)
fmt.Println("hello, world!")
}</p>
</div>`
Expect(RenderHTML(source)).To(MatchHTML(expected))
Expand Down Expand Up @@ -285,11 +285,11 @@ include::../../../test/includes/hello_world.go.txt[]`
<p>package includes</p>
</div>
<div class="paragraph">
<p>import &#34;fmt&#34;</p>
<p>import "fmt"</p>
</div>
<div class="paragraph">
<p>func helloworld() {
fmt.Println(&#34;hello, world!&#34;)
fmt.Println("hello, world!")
}</p>
</div>
</div>
Expand Down Expand Up @@ -455,10 +455,10 @@ include::../../../test/includes/hello_world.go.txt[]
<div class="content">
<pre>package includes
import &#34;fmt&#34;
import "fmt"
func helloworld() {
fmt.Println(&#34;hello, world!&#34;)
fmt.Println("hello, world!")
}</pre>
</div>
</div>`
Expand Down Expand Up @@ -493,11 +493,11 @@ include::../../../test/includes/hello_world.go.txt[]
<p>package includes</p>
</div>
<div class="paragraph">
<p>import &#34;fmt&#34;</p>
<p>import "fmt"</p>
</div>
<div class="paragraph">
<p>func helloworld() {
fmt.Println(&#34;hello, world!&#34;)
fmt.Println("hello, world!")
}</p>
</div>
</div>
Expand All @@ -515,11 +515,11 @@ ____`
<p>package includes</p>
</div>
<div class="paragraph">
<p>import &#34;fmt&#34;</p>
<p>import "fmt"</p>
</div>
<div class="paragraph">
<p>func helloworld() {
fmt.Println(&#34;hello, world!&#34;)
fmt.Println("hello, world!")
}</p>
</div>
</blockquote>
Expand All @@ -535,10 +535,10 @@ ____`
expected := `<div class="verseblock">
<pre class="content">package includes
import &#34;fmt&#34;
import "fmt"
func helloworld() {
fmt.Println(&#34;hello, world!&#34;)
fmt.Println("hello, world!")
}</pre>
</div>`
Expect(RenderHTML(source)).To(MatchHTML(expected))
Expand All @@ -554,11 +554,11 @@ include::../../../test/includes/hello_world.go.txt[]
<p>package includes</p>
</div>
<div class="paragraph">
<p>import &#34;fmt&#34;</p>
<p>import "fmt"</p>
</div>
<div class="paragraph">
<p>func helloworld() {
fmt.Println(&#34;hello, world!&#34;)
fmt.Println("hello, world!")
}</p>
</div>
</div>
Expand All @@ -584,7 +584,7 @@ include::../../../test/includes/hello_world.go.txt[]
source := `include::../../../test/includes/hello_world.go.txt[lines=5..7]`
expected := `<div class="paragraph">
<p>func helloworld() {
fmt.Println(&#34;hello, world!&#34;)
fmt.Println("hello, world!")
}</p>
</div>`
Expect(RenderHTML(source)).To(MatchHTML(expected))
Expand All @@ -597,7 +597,7 @@ include::../../../test/includes/hello_world.go.txt[]
</div>
<div class="paragraph">
<p>func helloworld() {
fmt.Println(&#34;hello, world!&#34;)
fmt.Println("hello, world!")
}</p>
</div>`
Expect(RenderHTML(source)).To(MatchHTML(expected))
Expand Down Expand Up @@ -625,7 +625,7 @@ include::../../../test/includes/hello_world.go.txt[lines=5..7]
expected := `<div class="listingblock">
<div class="content">
<pre>func helloworld() {
fmt.Println(&#34;hello, world!&#34;)
fmt.Println("hello, world!")
}</pre>
</div>
</div>`
Expand All @@ -641,7 +641,7 @@ include::../../../test/includes/hello_world.go.txt[lines=1..2;5..7]
<pre>package includes
func helloworld() {
fmt.Println(&#34;hello, world!&#34;)
fmt.Println("hello, world!")
}</pre>
</div>
</div>`
Expand Down
8 changes: 4 additions & 4 deletions pkg/renderer/html5/html5_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Free use of this software is granted under the terms of the MIT License.`
<h1>eve(1) Manual Page</h1>
<h2 id="_name">Name</h2>
<div class="sectionbody">
<p>eve - analyzes an image to determine if it&#39;s a picture of a life form</p>
<p>eve - analyzes an image to determine if it's a picture of a life form</p>
</div>
</div>
<div id="content">
Expand All @@ -203,7 +203,7 @@ Free use of this software is granted under the terms of the MIT License.`
</dd>
<dt class="hdlist1"><strong>-c, --capture</strong></dt>
<dd>
<p>Capture specimen if it&#39;s a picture of a life form.</p>
<p>Capture specimen if it's a picture of a life form.</p>
</dd>
</dl>
</div>
Expand Down Expand Up @@ -308,7 +308,7 @@ Free use of this software is granted under the terms of the MIT License.`

expected := `<h2 id="_name">Name</h2>
<div class="sectionbody">
<p>eve - analyzes an image to determine if it&#39;s a picture of a life form</p>
<p>eve - analyzes an image to determine if it's a picture of a life form</p>
</div>
<div class="sect1">
<h2 id="_synopsis">Synopsis</h2>
Expand All @@ -329,7 +329,7 @@ Free use of this software is granted under the terms of the MIT License.`
</dd>
<dt class="hdlist1"><strong>-c, --capture</strong></dt>
<dd>
<p>Capture specimen if it&#39;s a picture of a life form.</p>
<p>Capture specimen if it's a picture of a life form.</p>
</dd>
</dl>
</div>
Expand Down
4 changes: 2 additions & 2 deletions pkg/renderer/html5/html_escape.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ var htmlEscaper = strings.NewReplacer(
`&#`, "&#", // assume this is for an character entity and this keep as-is
// standard escape combinations
`&`, "&amp;",
`'`, "&#39;", // "&#39;" is shorter than "&apos;" and apos was not in HTML until HTML5.
`<`, "&lt;",
`>`, "&gt;",
`"`, "&#34;", // "&#34;" is shorter than "&quot;".
// `'`, "&#39;", // "&#39;" is shorter than "&apos;" and apos was not in HTML until HTML5.
// `"`, "&#34;", // "&#34;" is shorter than "&quot;".
)
2 changes: 1 addition & 1 deletion pkg/renderer/html5/labeled_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ item 2:: description 2.`
<dl>
<dt class="hdlist1">item 1</dt>
<dd>
<p>&lt;script&gt;alert(&#34;foo!&#34;)&lt;/script&gt;</p>
<p>&lt;script&gt;alert("foo!")&lt;/script&gt;</p>
</dd>
</dl>
</div>`
Expand Down
4 changes: 2 additions & 2 deletions pkg/renderer/html5/ordered_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,15 @@ print("one")
<p></p>
<div class="listingblock">
<div class="content">
<pre>print(&#34;one&#34;)</pre>
<pre>print("one")</pre>
</div>
</div>
</li>
<li>
<p></p>
<div class="listingblock">
<div class="content">
<pre>print(&#34;one&#34;)</pre>
<pre>print("one")</pre>
</div>
</div>
</li>
Expand Down
2 changes: 1 addition & 1 deletion pkg/renderer/html5/paragraph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ and here another paragraph
It("paragraph with single quotes", func() {
source := `a 'subsection' paragraph.`
expected := `<div class="paragraph">
<p>a &#39;subsection&#39; paragraph.</p>
<p>a 'subsection' paragraph.</p>
</div>`
Expect(RenderHTML(source)).To(MatchHTML(expected))
})
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/supported/lists.html
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ <h2 id="_lists">Lists</h2>
<p>level 3
This is a new line inside an unordered list using &#43; symbol.
We can even force content to start on a separate line&#8230;&#8203;<br>
Amazing, isn&#39;t it?</p>
Amazing, isn't it?</p>
<div class="ulist">
<ul>
<li>
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/supported/sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h2 id="id_section_a">Section A</h2>
<div class="sect2">
<h3 id="id_section_a_subsection">Section A Subsection</h3>
<div class="paragraph">
<p><strong>Section A</strong> &#39;subsection&#39; paragraph.</p>
<p><strong>Section A</strong> 'subsection' paragraph.</p>
</div>
</div>
</div>
Expand Down

0 comments on commit a02b80d

Please sign in to comment.