-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Typographer Edge Cases #280
Conversation
@natemoo-re Outstanding! Cc: @bep |
extension/typographer.go
Outdated
// special cases: 'twas, 'em, 'net | ||
if len(line) > 1 && (unicode.IsPunct(before) || unicode.IsSpace(before)) && (line[1] == 't' || line[1] == 'e' || line[1] == 'n' || line[1] == 'l') { | ||
fmt.Println(string(line)) | ||
node := gast.NewString(s.Substitutions[Apostrophe]) | ||
node.SetCode(true) | ||
block.Advance(1) | ||
return node | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only change I'm concerned about. I settled with t | e | n | l
covering most common abbreviations like 'twas
, 'em
, and 'net
but this is extremely difficult to generalize out to other abbreviations I might not have thought of.
@@ -64,3 +64,73 @@ reported "issue 1 (IE-only)", "issue 2", 'issue3 (FF-only)', 'issue4' | |||
//- - - - - - - - -// | |||
<p>“Monitor 21"” and “Monitor”"</p> | |||
//= = = = = = = = = = = = = = = = = = = = = = = =// | |||
|
|||
9: Closing quotation marks within italics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These test cases are all borrowed from https://gm-typographer.vercel.app/!
@natemoo-re Thanks for your contribution. Open source project should be like this. |
<p><strong>“At first, things were not clear.”</strong></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
11: Closing quotation marks within boldfacing and italics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are test cases 11&12 duplicated?
I mentioned I wanted to help with #180 quite a while ago. I finally found time to do it!
This PR fixes various edge cases with the Typographer extension, with test cases borrowed from @brycewray's https://gm-typographer.vercel.app/.
Closes #180, gohugoio/hugo#9397.
cc @brycewray @skyfaller