This commit is contained in:
yuin 2020-05-22 18:39:02 +09:00
parent 3393022ab6
commit 4709d43b81
2 changed files with 34 additions and 35 deletions

View file

@ -26,43 +26,34 @@ Some say '90s, others say 90's, but I can't say which is best.
<p>Some say &rsquo;90s, others say 90&rsquo;s, but I can&rsquo;t say which is best.</p> <p>Some say &rsquo;90s, others say 90&rsquo;s, but I can&rsquo;t say which is best.</p>
//= = = = = = = = = = = = = = = = = = = = = = = =// //= = = = = = = = = = = = = = = = = = = = = = = =//
5 5: contractions
//- - - - - - - - -//
[Cat][]'s Pajamas
[Cat]: http://example.com
//- - - - - - - - -//
<p><a href="http://example.com">Cat</a>&rsquo;s Pajamas</p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
6
//- - - - - - - - -//
reported "issue 1 (IE-only)"
//- - - - - - - - -//
<p>reported &ldquo;issue 1 (IE-only)&rdquo;</p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
7
//- - - - - - - - -//
Yahoo!'s
//- - - - - - - - -//
<p>Yahoo!&rsquo;s</p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
8
//- - - - - - - - -// //- - - - - - - - -//
Alice's, I'm ,Don't, You'd Alice's, I'm ,Don't, You'd
I've, I'll, You're I've, I'll, You're
[Cat][]'s Pajamas
Yahoo!'s
[Cat]: http://example.com
//- - - - - - - - -// //- - - - - - - - -//
<p>Alice&rsquo;s, I&rsquo;m ,Don&rsquo;t, You&rsquo;d</p> <p>Alice&rsquo;s, I&rsquo;m ,Don&rsquo;t, You&rsquo;d</p>
<p>I&rsquo;ve, I&rsquo;ll, You&rsquo;re</p> <p>I&rsquo;ve, I&rsquo;ll, You&rsquo;re</p>
<p><a href="http://example.com">Cat</a>&rsquo;s Pajamas</p>
<p>Yahoo!&rsquo;s</p>
//= = = = = = = = = = = = = = = = = = = = = = = =// //= = = = = = = = = = = = = = = = = = = = = = = =//
9 6: "" after digits are an inch
//- - - - - - - - -// //- - - - - - - - -//
My height is 5'6"". My height is 5'6"".
//- - - - - - - - -// //- - - - - - - - -//
<p>My height is 5'6&quot;&quot;.</p> <p>My height is 5'6&quot;&quot;.</p>
//= = = = = = = = = = = = = = = = = = = = = = = =// //= = = = = = = = = = = = = = = = = = = = = = = =//
7: quote followed by ,.?! and spaces maybe a closer
//- - - - - - - - -//
reported "issue 1 (IE-only)", "issue 2", 'issue3 (FF-only)', 'issue4'
//- - - - - - - - -//
<p>reported &ldquo;issue 1 (IE-only)&rdquo;, &ldquo;issue 2&rdquo;, &lsquo;issue3 (FF-only)&rsquo;, &lsquo;issue4&rsquo;</p>
//= = = = = = = = = = = = = = = = = = = = = = = =//

View file

@ -233,13 +233,17 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser
block.Advance(1) block.Advance(1)
return node return node
} }
if s.Substitutions[RightSingleQuote] != nil && d.CanClose && !d.CanOpen { if s.Substitutions[RightSingleQuote] != nil {
isClose := d.CanClose && !d.CanOpen
maybeClose := d.CanClose && d.CanOpen && len(line) > 1 && (line[1] == ',' || line[1] == '.' || line[1] == '!' || line[1] == '?') && (len(line) == 2 || (len(line) > 2 && util.IsPunct(line[2]) || util.IsSpace(line[2])))
if isClose || maybeClose {
node := gast.NewString(s.Substitutions[RightSingleQuote]) node := gast.NewString(s.Substitutions[RightSingleQuote])
node.SetCode(true) node.SetCode(true)
block.Advance(1) block.Advance(1)
return node return node
} }
} }
}
if c == '"' { if c == '"' {
// special case: 7'1"" // special case: 7'1""
if len(line) > 1 && line[1] == '"' && unicode.IsDigit(before) { if len(line) > 1 && line[1] == '"' && unicode.IsDigit(before) {
@ -253,7 +257,10 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser
block.Advance(1) block.Advance(1)
return node return node
} }
if s.Substitutions[RightDoubleQuote] != nil && d.CanClose && !d.CanOpen { if s.Substitutions[RightDoubleQuote] != nil {
isClose := d.CanClose && !d.CanOpen
maybeClose := d.CanClose && d.CanOpen && len(line) > 1 && (line[1] == ',' || line[1] == '.' || line[1] == '!' || line[1] == '?') && (len(line) == 2 || (len(line) > 2 && util.IsPunct(line[2]) || util.IsSpace(line[2])))
if isClose || maybeClose {
node := gast.NewString(s.Substitutions[RightDoubleQuote]) node := gast.NewString(s.Substitutions[RightDoubleQuote])
node.SetCode(true) node.SetCode(true)
block.Advance(1) block.Advance(1)
@ -261,6 +268,7 @@ func (s *typographerParser) Parse(parent gast.Node, block text.Reader, pc parser
} }
} }
} }
}
return nil return nil
} }