ignore underscore conditionally

pull/685/head
Dmitry Torba 2021-06-15 15:30:50 -07:00
parent 4c9bf95126
commit fe39a1fa08
1 changed files with 4 additions and 1 deletions

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
}