diff --git a/lib/parseHtml.test.ts b/lib/parseHtml.test.ts index 094681d19..ed3d1153a 100644 --- a/lib/parseHtml.test.ts +++ b/lib/parseHtml.test.ts @@ -14,6 +14,13 @@ describe('parseHtml', () => { it('handles missing html', () => { expect(() => trim()).not.toThrow() }) + it('handles links with spaces', () => { + const html = `
+ Hello +
` + + expect(trim(html)).toEqual('
Hello
') + }) }) describe('toMarkdown', () => { it('turns html into Markdown', () => { diff --git a/lib/parseHtml.ts b/lib/parseHtml.ts index 0f18d4062..cc01b6287 100644 --- a/lib/parseHtml.ts +++ b/lib/parseHtml.ts @@ -1,14 +1,27 @@ import * as h2m from 'h2m' import { htmlDecode } from 'js-htmlencode' -export const trim = (html: string = ''): string => html - .replace(/ /g, ' ') - .split('>') - .map((token) => token.trim()) - .join('>') - .split(' token.trim()) - .join(' { + const trimmed = html + .replace(/ /g, ' ') + .split('>') + .map((token) => token.trim()) + .join('>') + .split(' token.trim()) + .join('