Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Smartypants support for French Guillemets #379

Merged
merged 1 commit into from
Jul 28, 2017
Merged

Add Smartypants support for French Guillemets #379

merged 1 commit into from
Jul 28, 2017

Conversation

bep
Copy link
Contributor

@bep bep commented Jul 22, 2017

This commits adds flag HTML_SMARTYPANTS_QUOTES_NBSP which, when combined with HTML_USE_SMARTYPANTS will insert non-breaking spaces between the double quotes and the contained text.

This is mostly relevant for use in French with HTML_SMARTYPANTS_ANGLED_QUOTES.

It should not hurt existing code path in the performance department:

name                     old time/op    new time/op    delta
SmartDoubleQuotes-4    2.58µs ± 1%    2.58µs ± 1%   ~             (p=1.000 n=5+5)

name                     old alloc/op   new alloc/op   delta
SmartDoubleQuotes-4    5.27kB ± 0%    5.27kB ± 0%   ~     (all samples are equal)

name                     old allocs/op  new allocs/op  delta
SmartDoubleQuotes-4      13.0 ± 0%      13.0 ± 0%   ~     (all samples are equal)

Fixes #378

@rtfb
Copy link
Collaborator

rtfb commented Jul 27, 2017

The fix looks good. Would you also be willing to forward port it to v2? The internals of Smartypants haven't changed much there, IIRC.

@bep
Copy link
Contributor Author

bep commented Jul 27, 2017

The fix looks good. Would you also be willing to forward port it to v2?

No problem, I will do that in a separate PR. I created #380 to track/remind me of it.

smartypants.go Outdated
func smartypants(flags int) *smartypantsRenderer {
r := new(smartypantsRenderer)
addNbsp := flags&HTML_SMARTYPANTS_QUOTES_NBSP != 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit, addNBSP, see https://golang.org/s/style#initialisms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed.

This commits adds flag `HTML_SMARTYPANTS_QUOTES_NBSP` which, when combined with `HTML_USE_SMARTYPANTS` will insert non-breaking spaces between the double quotes and the contained text.

This is mostly relevant for use in French  with `HTML_SMARTYPANTS_ANGLED_QUOTES`.

It should not hurt existing code path in the performance department:

```
name                     old time/op    new time/op    delta
SmartDoubleQuotes-4    2.58µs ± 1%    2.58µs ± 1%   ~             (p=1.000 n=5+5)

name                     old alloc/op   new alloc/op   delta
SmartDoubleQuotes-4    5.27kB ± 0%    5.27kB ± 0%   ~     (all samples are equal)

name                     old allocs/op  new allocs/op  delta
SmartDoubleQuotes-4      13.0 ± 0%      13.0 ± 0%   ~     (all samples are equal)
```

Fixes #378
@rtfb rtfb merged commit 4048872 into russross:master Jul 28, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants