Skip to content
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

Merged
merged 5 commits into from
Feb 18, 2022
Merged

Conversation

natemoo-re
Copy link
Contributor

@natemoo-re natemoo-re commented Feb 17, 2022

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

@brycewray
Copy link

@natemoo-re Outstanding!

Cc: @bep

Comment on lines 234 to 241
// 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
}
Copy link
Contributor Author

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>&ldquo;Monitor 21&quot;&rdquo; and &ldquo;Monitor&rdquo;&quot;</p>
//= = = = = = = = = = = = = = = = = = = = = = = =//

9: Closing quotation marks within italics
Copy link
Contributor Author

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/!

@yuin
Copy link
Owner

yuin commented Feb 18, 2022

@natemoo-re Thanks for your contribution. Open source project should be like this.

@yuin yuin merged commit 1def545 into yuin:master Feb 18, 2022
<p><strong>&ldquo;At first, things were not clear.&rdquo;</strong></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//

11: Closing quotation marks within boldfacing and italics

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plural possessives (Typographer extension)
4 participants