Skip to content

Commit

Permalink
fix: 🐛 Flytta mellanslag utanför taggarna (kolplattformen#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
kajetan-kazimierczak authored Apr 27, 2021
1 parent 4991f91 commit 79e2a75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/parse/__tests__/news.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe('newsItem', () => {
BannerImageGuid: '7a8142d9d9d54cf090e8457e4c629227',
BannerImageListId: 'a88c22e8-7094-4a71-b4fd-8792c62a7b4a',
Body:
'<i>italic</i> <b>bold</b> <em>emphasis </em><br/><strong>strong</strong>',
'<i>italic</i> <b>bold</b> <em>emphasis </em><br/><strong>strong</strong><strong>nbsp&#160;</strong>',
BodyNoHtml: null,
AuthorDisplayName: 'Tieto Evry',
altText: null,
Expand Down Expand Up @@ -238,5 +238,6 @@ describe('newsItem', () => {
expect(item.body).toContain('**bold**')
expect(item.body).toContain('*emphasis*')
expect(item.body).toContain('**strong**')
expect(item.body).toContain('**nbsp**')
})
})
2 changes: 2 additions & 0 deletions lib/parseHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const rearrangeWhitespace = (html: string = ''): string => {
trimNodes.forEach((trimNode) => {
content = content.split(`<${trimNode}> `).join(` <${trimNode}>`)
content = content.split(` </${trimNode}>`).join(`</${trimNode}> `)
content = content.split(`<${trimNode}>&amp;nbsp;`).join(`&amp;nbsp;<${trimNode}>`)
content = content.split(`&amp;nbsp;</${trimNode}>`).join(`</${trimNode}>&amp;nbsp;`)
})
return content
}
Expand Down

0 comments on commit 79e2a75

Please sign in to comment.