Skip to content

Commit cb9dfc2

Browse files
committed
helpers: Add support for French Guillemets
Fixes #3725
1 parent c4a0b6e commit cb9dfc2

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

‎docs/content/readfiles/bfconfig.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
Blackfriday flag: **`HTML_USE_SMARTYPANTS`** <br>
99
Purpose: `false` disables smart punctuation substitutions, including smart quotes, smart dashes, smart fractions, etc. If `true`, it may be fine-tuned with the `angledQuotes`, `fractions`, `smartDashes`, and `latexDashes` flags (see below).
1010

11+
`smartypantsQuotesNBSP`
12+
: default: **`false`** <br>
13+
Blackfriday flag: **`HTML_SMARTYPANTS_QUOTES_NBSP`** <br>
14+
Purpose: `true` enables French style Guillemets with non-breaking space inside the quotes.
15+
1116
`angledQuotes`
1217
: default: **`false`**<br>
1318
Blackfriday flag: **`HTML_SMARTYPANTS_ANGLED_QUOTES`**<br>

‎helpers/content.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func NewContentSpec(cfg config.Provider) *ContentSpec {
6363
// Blackfriday holds configuration values for Blackfriday rendering.
6464
type Blackfriday struct {
6565
Smartypants bool
66+
SmartypantsQuotesNBSP bool
6667
AngledQuotes bool
6768
Fractions bool
6869
HrefTargetBlank bool
@@ -81,6 +82,7 @@ func (c ContentSpec) NewBlackfriday() *Blackfriday {
8182
defaultParam := map[string]interface{}{
8283
"smartypants": true,
8384
"angledQuotes": false,
85+
"smartypantsQuotesNBSP": false,
8486
"fractions": true,
8587
"hrefTargetBlank": false,
8688
"smartDashes": true,
@@ -229,6 +231,10 @@ func (c ContentSpec) getHTMLRenderer(defaultFlags int, ctx *RenderingContext) bl
229231
htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS
230232
}
231233

234+
if ctx.Config.SmartypantsQuotesNBSP {
235+
htmlFlags |= blackfriday.HTML_SMARTYPANTS_QUOTES_NBSP
236+
}
237+
232238
if ctx.Config.AngledQuotes {
233239
htmlFlags |= blackfriday.HTML_SMARTYPANTS_ANGLED_QUOTES
234240
}

‎helpers/content_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ func TestGetHTMLRendererAllFlags(t *testing.T) {
171171
{blackfriday.HTML_USE_XHTML},
172172
{blackfriday.HTML_FOOTNOTE_RETURN_LINKS},
173173
{blackfriday.HTML_USE_SMARTYPANTS},
174+
{blackfriday.HTML_SMARTYPANTS_QUOTES_NBSP},
174175
{blackfriday.HTML_SMARTYPANTS_ANGLED_QUOTES},
175176
{blackfriday.HTML_SMARTYPANTS_FRACTIONS},
176177
{blackfriday.HTML_HREF_TARGET_BLANK},
@@ -186,6 +187,7 @@ func TestGetHTMLRendererAllFlags(t *testing.T) {
186187
ctx.Config.PlainIDAnchors = true
187188
ctx.Config.SmartDashes = true
188189
ctx.Config.Smartypants = true
190+
ctx.Config.SmartypantsQuotesNBSP = true
189191
ctx.Config.SourceRelativeLinksEval = true
190192
renderer := c.getHTMLRenderer(defaultFlags, ctx)
191193
actualFlags := renderer.GetFlags()

0 commit comments

Comments
 (0)