Skip to content

Commit

Permalink
improve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
eh2077 committed Jun 13, 2023
1 parent f5e2db6 commit 85df9f8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,12 @@ export default class ExpensiMark {
name: 'italic',
regex: /(\b_+|\b)(?!_blank")_((?![\s_])[\s\S]*?[^\s_])_(?![^\W_])(?![^<]*(<\/pre>|<\/code>|<\/a>|<\/mention-user>|_blank))/g,

// g1 is empty string or includes one or more underscores, eg: `hello ___world_`
// We want to add g1 back before the <em> tag
replacement: (match, g1, g2) => (g2.includes('<pre>') || this.containsNonPairTag(g2) ? match : `${g1}<em>${g2}</em>`),
// We want to add extraLeadingUnderscores back before the <em> tag
replacement: (match, extraLeadingUnderscores, textWithinUnderscores) => (
textWithinUnderscores.includes('<pre>') || this.containsNonPairTag(textWithinUnderscores)
? match
: `${extraLeadingUnderscores}<em>${textWithinUnderscores}</em>`
),
},
{
// Use \B in this case because \b doesn't match * or ~.
Expand Down

0 comments on commit 85df9f8

Please sign in to comment.