From a02b80d36516c3b4cd21ef94d3208b344d917996 Mon Sep 17 00:00:00 2001
From: Xavier Coulon
Date: Sat, 23 May 2020 15:20:37 +0200
Subject: [PATCH] refactor(renderer): discard quote replacement in HTML
No need to replace ' and " with ' and "
Fixes #565
Signed-off-by: Xavier Coulon
---
libasciidoc_test.go | 6 ++--
pkg/renderer/html5/delimited_block_test.go | 26 ++++++++--------
pkg/renderer/html5/file_inclusion_test.go | 36 +++++++++++-----------
pkg/renderer/html5/html5_test.go | 8 ++---
pkg/renderer/html5/html_escape.go | 4 +--
pkg/renderer/html5/labeled_list_test.go | 2 +-
pkg/renderer/html5/ordered_list_test.go | 4 +--
pkg/renderer/html5/paragraph_test.go | 2 +-
test/fixtures/supported/lists.html | 2 +-
test/fixtures/supported/sample.html | 2 +-
10 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/libasciidoc_test.go b/libasciidoc_test.go
index 84e2279f..b5905f6e 100644
--- a/libasciidoc_test.go
+++ b/libasciidoc_test.go
@@ -296,7 +296,7 @@ Free use of this software is granted under the terms of the MIT License.`
expectedContent := `Name
-
eve - analyzes an image to determine if it's a picture of a life form
+
eve - analyzes an image to determine if it's a picture of a life form
Synopsis
@@ -355,7 +355,7 @@ Free use of this software is granted under the terms of the MIT License.`
eve(1) Manual Page
Name
-
eve - analyzes an image to determine if it's a picture of a life form
+
eve - analyzes an image to determine if it's a picture of a life form
@@ -434,7 +434,7 @@ Free use of this software is granted under the terms of the MIT License.`
Foo
-
eve - analyzes an image to determine if it's a picture of a life form
+
eve - analyzes an image to determine if it's a picture of a life form
diff --git a/pkg/renderer/html5/delimited_block_test.go b/pkg/renderer/html5/delimited_block_test.go
index f75cdf39..7d70d6dd 100644
--- a/pkg/renderer/html5/delimited_block_test.go
+++ b/pkg/renderer/html5/delimited_block_test.go
@@ -130,10 +130,10 @@ end
----`
expected := `
-
require 'sinatra'
+require 'sinatra'
-get '/hi' do
- "Hello World!"
+get '/hi' do
+ "Hello World!"
end
`
@@ -154,10 +154,10 @@ end
expected := `
Source block title
-
require 'sinatra'
+require 'sinatra'
-get '/hi' do
- "Hello World!"
+get '/hi' do
+ "Hello World!"
end
`
@@ -178,10 +178,10 @@ end
expected := `
Source block title
-
require 'sinatra'
+require 'sinatra'
-get '/hi' do
- "Hello World!"
+get '/hi' do
+ "Hello World!"
end
`
@@ -202,10 +202,10 @@ end
expected := `
app.rb
-
require 'sinatra'
+require 'sinatra'
-get '/hi' do
- "Hello World!"
+get '/hi' do
+ "Hello World!"
end
`
@@ -297,7 +297,7 @@ and "more" content
bold content
-
and "more" content
+
and "more" content
`
diff --git a/pkg/renderer/html5/file_inclusion_test.go b/pkg/renderer/html5/file_inclusion_test.go
index dd1df776..3fd86f6b 100644
--- a/pkg/renderer/html5/file_inclusion_test.go
+++ b/pkg/renderer/html5/file_inclusion_test.go
@@ -234,11 +234,11 @@ include::../../../test/includes/hello_world.go.txt[]`
package includes
-
import "fmt"
+
import "fmt"
func helloworld() {
- fmt.Println("hello, world!")
+ fmt.Println("hello, world!")
}
`
Expect(RenderHTML(source)).To(MatchHTML(expected))
@@ -285,11 +285,11 @@ include::../../../test/includes/hello_world.go.txt[]`
package includes
-
import "fmt"
+
import "fmt"
func helloworld() {
- fmt.Println("hello, world!")
+ fmt.Println("hello, world!")
}
@@ -455,10 +455,10 @@ include::../../../test/includes/hello_world.go.txt[]
package includes
-import "fmt"
+import "fmt"
func helloworld() {
- fmt.Println("hello, world!")
+ fmt.Println("hello, world!")
}
`
@@ -493,11 +493,11 @@ include::../../../test/includes/hello_world.go.txt[]
package includes
-
import "fmt"
+
import "fmt"
func helloworld() {
- fmt.Println("hello, world!")
+ fmt.Println("hello, world!")
}
@@ -515,11 +515,11 @@ ____`
package includes
-
import "fmt"
+
import "fmt"
func helloworld() {
- fmt.Println("hello, world!")
+ fmt.Println("hello, world!")
}
@@ -535,10 +535,10 @@ ____`
expected := `
package includes
-import "fmt"
+import "fmt"
func helloworld() {
- fmt.Println("hello, world!")
+ fmt.Println("hello, world!")
}
`
Expect(RenderHTML(source)).To(MatchHTML(expected))
@@ -554,11 +554,11 @@ include::../../../test/includes/hello_world.go.txt[]
package includes
-
import "fmt"
+
import "fmt"
func helloworld() {
- fmt.Println("hello, world!")
+ fmt.Println("hello, world!")
}
@@ -584,7 +584,7 @@ include::../../../test/includes/hello_world.go.txt[]
source := `include::../../../test/includes/hello_world.go.txt[lines=5..7]`
expected := `
func helloworld() {
- fmt.Println("hello, world!")
+ fmt.Println("hello, world!")
}
`
Expect(RenderHTML(source)).To(MatchHTML(expected))
@@ -597,7 +597,7 @@ include::../../../test/includes/hello_world.go.txt[]
func helloworld() {
- fmt.Println("hello, world!")
+ fmt.Println("hello, world!")
}
`
Expect(RenderHTML(source)).To(MatchHTML(expected))
@@ -625,7 +625,7 @@ include::../../../test/includes/hello_world.go.txt[lines=5..7]
expected := `
func helloworld() {
- fmt.Println("hello, world!")
+ fmt.Println("hello, world!")
}
`
@@ -641,7 +641,7 @@ include::../../../test/includes/hello_world.go.txt[lines=1..2;5..7]
package includes
func helloworld() {
- fmt.Println("hello, world!")
+ fmt.Println("hello, world!")
}
`
diff --git a/pkg/renderer/html5/html5_test.go b/pkg/renderer/html5/html5_test.go
index 573a74d2..eeea192b 100644
--- a/pkg/renderer/html5/html5_test.go
+++ b/pkg/renderer/html5/html5_test.go
@@ -180,7 +180,7 @@ Free use of this software is granted under the terms of the MIT License.`
eve(1) Manual Page
Name
-
eve - analyzes an image to determine if it's a picture of a life form
+
eve - analyzes an image to determine if it's a picture of a life form
@@ -203,7 +203,7 @@ Free use of this software is granted under the terms of the MIT License.`
-c, --capture
-Capture specimen if it's a picture of a life form.
+Capture specimen if it's a picture of a life form.
@@ -308,7 +308,7 @@ Free use of this software is granted under the terms of the MIT License.`
expected := `Name
-
eve - analyzes an image to determine if it's a picture of a life form
+
eve - analyzes an image to determine if it's a picture of a life form
Synopsis
@@ -329,7 +329,7 @@ Free use of this software is granted under the terms of the MIT License.`
-c, --capture
-Capture specimen if it's a picture of a life form.
+Capture specimen if it's a picture of a life form.
diff --git a/pkg/renderer/html5/html_escape.go b/pkg/renderer/html5/html_escape.go
index f28541da..b2f21711 100644
--- a/pkg/renderer/html5/html_escape.go
+++ b/pkg/renderer/html5/html_escape.go
@@ -17,8 +17,8 @@ var htmlEscaper = strings.NewReplacer(
``, "", // assume this is for an character entity and this keep as-is
// standard escape combinations
`&`, "&",
- `'`, "'", // "'" is shorter than "'" and apos was not in HTML until HTML5.
`<`, "<",
`>`, ">",
- `"`, """, // """ is shorter than """.
+ // `'`, "'", // "'" is shorter than "'" and apos was not in HTML until HTML5.
+ // `"`, """, // """ is shorter than """.
)
diff --git a/pkg/renderer/html5/labeled_list_test.go b/pkg/renderer/html5/labeled_list_test.go
index b1a0c51b..885a30cf 100644
--- a/pkg/renderer/html5/labeled_list_test.go
+++ b/pkg/renderer/html5/labeled_list_test.go
@@ -95,7 +95,7 @@ item 2:: description 2.`
- item 1
-
-
<script>alert("foo!")</script>
+<script>alert("foo!")</script>
`
diff --git a/pkg/renderer/html5/ordered_list_test.go b/pkg/renderer/html5/ordered_list_test.go
index da6c5f54..73528d6b 100644
--- a/pkg/renderer/html5/ordered_list_test.go
+++ b/pkg/renderer/html5/ordered_list_test.go
@@ -367,7 +367,7 @@ print("one")
-
print("one")
+
print("one")
@@ -375,7 +375,7 @@ print("one")
-
print("one")
+
print("one")
diff --git a/pkg/renderer/html5/paragraph_test.go b/pkg/renderer/html5/paragraph_test.go
index 5e4f2a39..8c19816e 100644
--- a/pkg/renderer/html5/paragraph_test.go
+++ b/pkg/renderer/html5/paragraph_test.go
@@ -61,7 +61,7 @@ and here another paragraph
It("paragraph with single quotes", func() {
source := `a 'subsection' paragraph.`
expected := `
-
a 'subsection' paragraph.
+
a 'subsection' paragraph.
`
Expect(RenderHTML(source)).To(MatchHTML(expected))
})
diff --git a/test/fixtures/supported/lists.html b/test/fixtures/supported/lists.html
index 005c14c6..ed0a6b25 100644
--- a/test/fixtures/supported/lists.html
+++ b/test/fixtures/supported/lists.html
@@ -309,7 +309,7 @@ Lists
level 3
This is a new line inside an unordered list using + symbol.
We can even force content to start on a separate line…
-Amazing, isn't it?
+Amazing, isn't it?
-
diff --git a/test/fixtures/supported/sample.html b/test/fixtures/supported/sample.html
index 54c0e600..724a9d5e 100644
--- a/test/fixtures/supported/sample.html
+++ b/test/fixtures/supported/sample.html
@@ -26,7 +26,7 @@
Section A
Section A Subsection
-
Section A 'subsection' paragraph.
+
Section A 'subsection' paragraph.