Skip to content

Commit 4862ce8

Browse files
Tsuk1kodscho
authored andcommitted
Trim whitespace in XML nodes and improve Markdown conversion
1 parent ab1d370 commit 4862ce8

File tree

4 files changed

+11
-21
lines changed

4 files changed

+11
-21
lines changed

__tests__/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const https = require('https')
33

44
jest.mock('@actions/core')
55
jest.mock('@actions/github')
6-
jest.mock('turndown')
6+
jest.mock('html-to-md')
77

88
const core = require('@actions/core')
99
const { getOctokit, context } = require('@actions/github')

index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const core = require('@actions/core')
22
const { getOctokit, context } = require('@actions/github')
33
const RSSParser = require('rss-parser')
4-
const TurnDown = require('turndown')
4+
const html2md = require('html-to-md')
55

66
const parseDurationInMilliseconds = (text) => {
77
let ms = 0
@@ -43,7 +43,7 @@ const run = async () => {
4343
const octokit = getOctokit(core.getInput('github-token'))
4444

4545
// Instantiate feed parser
46-
const feed = await (new RSSParser()).parseURL(core.getInput('feed'))
46+
const feed = await (new RSSParser({ xml2js: { trim: true } })).parseURL(core.getInput('feed'))
4747
core.info(feed && feed.title)
4848
if (!feed.items || feed.items.length === 0) return
4949

@@ -58,8 +58,6 @@ const run = async () => {
5858
})
5959
core.debug(`${issues.length} issues`)
6060

61-
const turndownService = new TurnDown()
62-
6361
const createdIssues = []
6462

6563
// Iterate
@@ -91,7 +89,7 @@ const run = async () => {
9189
continue
9290
}
9391

94-
let markdown = turndownService.turndown(content)
92+
let markdown = html2md(content)
9593

9694
// truncate if characterLimit > 0
9795
if (characterLimit && markdown.length > characterLimit) {

package-lock.json

Lines changed: 5 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"dependencies": {
2929
"@actions/core": "^1.10.0",
3030
"@actions/github": "^4.0.0",
31-
"rss-parser": "^3.12.0",
32-
"turndown": "^7.0.0"
31+
"html-to-md": "^0.5.3",
32+
"rss-parser": "^3.12.0"
3333
},
3434
"devDependencies": {
3535
"@vercel/ncc": "^0.28.2",

0 commit comments

Comments
 (0)