diff options
| author | Shulhan <ms@kilabit.info> | 2020-12-26 17:23:03 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2020-12-26 17:23:03 +0700 |
| commit | ff8a9955a153deebe7c55b8f748b429ea157ee73 (patch) | |
| tree | 56b23d8f9f199fb40679724d2f16475d3bb9f645 | |
| parent | e39ff0f9ee29f290fcd5eedb94309db71fa78d25 (diff) | |
| download | asciidoctor-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.go | 1 | ||||
| -rw-r--r-- | inline_parser.go | 8 | ||||
| -rw-r--r-- | testdata/got.test.html | 3 |
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 = "←" htmlSymbolSingleQuote = "'" htmlSymbolSingleRightArrow = "→" + htmlSymbolThinSpace = " " htmlSymbolTrademark = "™" htmlSymbolWordJoiner = "⁠" htmlSymbolZeroWidthSpace = "​" 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" -— Thomas Jefferson, Papers of Thomas Jefferson: Volume 11</p> +<p>it that" — Thomas Jefferson, Papers of Thomas Jefferson: Volume 11</p> </div> <div class="ulist"> <ul> |
