From 38cc6e9ae8efc66a78d18737bd5e269ae672300d Mon Sep 17 00:00:00 2001 From: Anthony Fok Date: Mon, 3 Aug 2015 23:57:26 -0600 Subject: [PATCH] Add HTML_SMARTYPANTS_DASHES for toggling smart dashes --- html.go | 3 ++- markdown.go | 1 + smartypants.go | 10 ++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/html.go b/html.go index 264aae5..74e67ee 100644 --- a/html.go +++ b/html.go @@ -39,7 +39,8 @@ const ( HTML_USE_XHTML // generate XHTML output instead of HTML HTML_USE_SMARTYPANTS // enable smart punctuation substitutions HTML_SMARTYPANTS_FRACTIONS // enable smart fractions (with HTML_USE_SMARTYPANTS) - HTML_SMARTYPANTS_LATEX_DASHES // enable LaTeX-style dashes (with HTML_USE_SMARTYPANTS) + HTML_SMARTYPANTS_DASHES // enable smart dashes (with HTML_USE_SMARTYPANTS) + HTML_SMARTYPANTS_LATEX_DASHES // enable LaTeX-style dashes (with HTML_USE_SMARTYPANTS and HTML_SMARTYPANTS_DASHES) HTML_SMARTYPANTS_ANGLED_QUOTES // enable angled double quotes (with HTML_USE_SMARTYPANTS) for double quotes rendering HTML_FOOTNOTE_RETURN_LINKS // generate a link at the end of a footnote to return to the source ) diff --git a/markdown.go b/markdown.go index c61b006..91dfb3c 100644 --- a/markdown.go +++ b/markdown.go @@ -50,6 +50,7 @@ const ( HTML_USE_XHTML | HTML_USE_SMARTYPANTS | HTML_SMARTYPANTS_FRACTIONS | + HTML_SMARTYPANTS_DASHES | HTML_SMARTYPANTS_LATEX_DASHES commonExtensions = 0 | diff --git a/smartypants.go b/smartypants.go index 8027571..eeffa5e 100644 --- a/smartypants.go +++ b/smartypants.go @@ -378,10 +378,12 @@ func smartypants(flags int) *smartypantsRenderer { } r['\''] = smartSingleQuote r['('] = smartParens - if flags&HTML_SMARTYPANTS_LATEX_DASHES == 0 { - r['-'] = smartDash - } else { - r['-'] = smartDashLatex + if flags&HTML_SMARTYPANTS_DASHES != 0 { + if flags&HTML_SMARTYPANTS_LATEX_DASHES == 0 { + r['-'] = smartDash + } else { + r['-'] = smartDashLatex + } } r['.'] = smartPeriod if flags&HTML_SMARTYPANTS_FRACTIONS == 0 {