summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2020-12-26 17:23:03 +0700
committerShulhan <ms@kilabit.info>2020-12-26 17:23:03 +0700
commitff8a9955a153deebe7c55b8f748b429ea157ee73 (patch)
tree56b23d8f9f199fb40679724d2f16475d3bb9f645
parente39ff0f9ee29f290fcd5eedb94309db71fa78d25 (diff)
downloadasciidoctor-go-ff8a9955a153deebe7c55b8f748b429ea157ee73.tar.xz
all: replace space surrounding the em-dash with html symbol thin space
If the em-dash strings "--" flanked by space, replace the space with HTML symbol thin space.
-rw-r--r--html_backend.go1
-rw-r--r--inline_parser.go8
-rw-r--r--testdata/got.test.html3
3 files changed, 10 insertions, 2 deletions
diff --git a/html_backend.go b/html_backend.go
index 2f7139c..89d3a86 100644
--- a/html_backend.go
+++ b/html_backend.go
@@ -55,6 +55,7 @@ const (
htmlSymbolSingleLeftArrow = "&#8592;"
htmlSymbolSingleQuote = "&#39;"
htmlSymbolSingleRightArrow = "&#8594;"
+ htmlSymbolThinSpace = "&#8201;"
htmlSymbolTrademark = "&#8482;"
htmlSymbolWordJoiner = "&#8288;"
htmlSymbolZeroWidthSpace = "&#8203;"
diff --git a/inline_parser.go b/inline_parser.go
index cf1b392..872a669 100644
--- a/inline_parser.go
+++ b/inline_parser.go
@@ -302,7 +302,15 @@ func (pi *inlineParser) do() {
}
if pi.prev != '-' {
if pi.nextc == '-' && pi.nextcc != '-' {
+ if ascii.IsSpace(pi.prev) && ascii.IsSpace(pi.nextcc) {
+ pi.current.backTrimSpace()
+ pi.current.WriteString(htmlSymbolThinSpace)
+ }
pi.current.WriteString(htmlSymbolEmdash)
+ if ascii.IsSpace(pi.nextcc) {
+ pi.current.WriteString(htmlSymbolThinSpace)
+ pi.x++
+ }
pi.x += 2
pi.prev = pi.nextc
continue
diff --git a/testdata/got.test.html b/testdata/got.test.html
index 5e99975..4dc6806 100644
--- a/testdata/got.test.html
+++ b/testdata/got.test.html
@@ -2864,8 +2864,7 @@ Author with tab
</div>
</div>
<div class="paragraph">
-<p>it that"
-&#8212; Thomas Jefferson, Papers of Thomas Jefferson: Volume 11</p>
+<p>it that"&#8201;&#8212;&#8201;Thomas Jefferson, Papers of Thomas Jefferson: Volume 11</p>
</div>
<div class="ulist">
<ul>