Merge pull request #13652 from IAvecilla/fix-underscore-display

fix(cli): keep snake_case underscores intact in strip markdown mode
This commit is contained in:
Jeffrey Quesnelle
2026-04-21 15:09:36 -04:00
committed by GitHub
4 changed files with 37 additions and 5 deletions

View File

@@ -97,4 +97,12 @@ describe('estimateRows', () => {
expect(estimateRows(md, 40)).toBe(2)
})
it('keeps intraword underscores when sizing snake_case identifiers', () => {
const w = 80
const snake = 'look at test_case_with_underscores now'
const plain = 'look at test case with underscores now'
expect(estimateRows(snake, w)).toBe(estimateRows(plain, w))
})
})

View File

@@ -25,9 +25,9 @@ const renderEstimateLine = (line: string) => {
.replace(/\[(.+?)\]\((https?:\/\/[^\s)]+)\)/g, '$1')
.replace(/`([^`]+)`/g, '$1')
.replace(/\*\*(.+?)\*\*/g, '$1')
.replace(/__(.+?)__/g, '$1')
.replace(/(?<!\w)__(.+?)__(?!\w)/g, '$1')
.replace(/\*(.+?)\*/g, '$1')
.replace(/_(.+?)_/g, '$1')
.replace(/(?<!\w)_(.+?)_(?!\w)/g, '$1')
.replace(/~~(.+?)~~/g, '$1')
.replace(/==(.+?)==/g, '$1')
.replace(/\[\^([^\]]+)\]/g, '[$1]')