ignore underscore conditionally

This commit is contained in:
Dmitry Torba 2021-06-15 15:30:50 -07:00
parent 4c9bf95126
commit fe39a1fa08

View File

@ -47,6 +47,7 @@ const (
AutoHeadingIDs // Create the heading ID from the text
BackslashLineBreak // Translate trailing backslashes into line breaks
DefinitionLists // Render definition lists
IgnoreUnderscore // Ignore all underscores
CommonHTMLFlags HTMLFlags = UseXHTML | Smartypants |
SmartypantsFractions | SmartypantsDashes | SmartypantsLatexDashes
@ -285,7 +286,9 @@ func New(opts ...Option) *Markdown {
// register inline parsers
p.inlineCallback[' '] = maybeLineBreak
p.inlineCallback['*'] = emphasis
p.inlineCallback['_'] = emphasis
if p.extensions&IgnoreUnderscore == 0 {
p.inlineCallback['_'] = emphasis
}
if p.extensions&Strikethrough != 0 {
p.inlineCallback['~'] = emphasis
}