From 483fc8fa3dd8db7d399ef5ed05a3b7f42ea19152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 28 Jun 2015 15:18:15 +0200 Subject: [PATCH] Add config option for Blackfriday HTML_HREF_TARGET_BLANK Fixes #1220 --- helpers/content.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/helpers/content.go b/helpers/content.go index b80f600a7..cd4563441 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -40,21 +40,23 @@ var SummaryDivider = []byte("") // Blackfriday holds configuration values for Blackfriday rendering. type Blackfriday struct { - AngledQuotes bool - Fractions bool - LatexDashes bool - PlainIDAnchors bool - Extensions []string - ExtensionsMask []string + AngledQuotes bool + Fractions bool + HrefTargetBlank bool + LatexDashes bool + PlainIDAnchors bool + Extensions []string + ExtensionsMask []string } // NewBlackfriday creates a new Blackfriday with some sane defaults. func NewBlackfriday() *Blackfriday { return &Blackfriday{ - AngledQuotes: false, - Fractions: true, - LatexDashes: true, - PlainIDAnchors: false, + AngledQuotes: false, + Fractions: true, + HrefTargetBlank: false, + LatexDashes: true, + PlainIDAnchors: false, } } @@ -157,6 +159,10 @@ func GetHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Render htmlFlags |= blackfriday.HTML_SMARTYPANTS_FRACTIONS } + if ctx.getConfig().HrefTargetBlank { + htmlFlags |= blackfriday.HTML_HREF_TARGET_BLANK + } + if ctx.getConfig().LatexDashes { htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES }