| 8 | | 8 | |
| 9 | return [{ | 9 | return [{ |
| 10 | type: 'lang', | 10 | type: 'lang', |
| 11 | regex: new RegExp('\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'g'), | 11 | regex: new RegExp('(`{1,3}).*?\\1|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'gs'), |
| 12 | replace: '<em>$1</em>', | 12 | replace: function(match, codeBlock, italicContent) { |
| | 13 | if (codeBlock) { |
| | 14 | // If it's a code block, return it unchanged |
| | 15 | return match; |
| | 16 | } else { |
| | 17 | // If it's an italic group, apply the replacement |
| | 18 | return `<em>${italicContent}</em>`; |
| | 19 | } |
| | 20 | }, |
| 13 | }]; | 21 | }]; |
| 14 | } catch (e) { | 22 | } catch (e) { |
| 15 | console.error('Error in Showdown-underscore extension:', e); | 23 | console.error('Error in Showdown-underscore extension:', e); |