Skip to content

Commit 955c0ec

Browse files
committed
fixes for jsr publish
1 parent 51cd59c commit 955c0ec

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
66

7-
http://www.apache.org/licenses/LICENSE-2.0
7+
http://www.apache.org/licenses/LICENSE-2.0
88

99
Unless required by applicable law or agreed to in writing, software
1010
distributed under the License is distributed on an "AS IS" BASIS,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"scripts": {
99
"lint": "eslint .",
1010
"prettier": "prettier --check .",
11+
"prettier-fix": "prettier --write .",
1112
"test": "vitest",
1213
"generate-testcase": "node test/generate-testcase.js",
1314
"build": "tsup src/index.ts --format cjs,esm --dts",

src/dom.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import { type Cheerio, type Element, type AnyNode } from 'cheerio'
2-
import { removeElement } from 'domutils'
1+
import {
2+
type Cheerio,
3+
type Element,
4+
type AnyNode,
5+
type CheerioAPI,
6+
} from 'cheerio'
37

48
import { whitespace } from './regexes.js'
59

@@ -15,17 +19,17 @@ export function removeNodes(
1519
}
1620
}
1721

18-
export function removeComments(node: AnyNode) {
22+
export function removeComments($: CheerioAPI, node: AnyNode) {
1923
if ((node.type === 'tag' || node.type === 'root') && node.children) {
2024
for (let i = node.children.length - 1; i >= 0; i--) {
21-
removeComments(node.children[i]!)
25+
removeComments($, node.children[i]!)
2226
}
2327
} else if (
2428
node.type === 'comment' ||
2529
node.type === 'directive' ||
2630
node.type === 'cdata'
2731
) {
28-
return removeElement(node)
32+
return $(node).remove()
2933
}
3034
}
3135

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ export class Readability {
17451745

17461746
if (this.options.extraction) {
17471747
// Remove all comments
1748-
removeComments(this.$.root()[0])
1748+
removeComments(this.$, this.$.root()[0])
17491749

17501750
// Remove all scripts once we've got the metadata
17511751
removeNodes(this.$('script, noscript'))

src/utils/simplifyDivs.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ describe('simplifyDivs', () => {
88
const node = $('#content')[0]!
99
simplifyDivs($, node)
1010
return expect($.html()).toBe(
11-
`<html><head></head><body><div id="content">${expectation}</div></body></html>`
11+
`<html><head></head><body><div id="content">${expectation}</div></body></html>`,
1212
)
1313
}
1414

1515
it('should wrap sequences of phrasing content in <p> tags', () => {
1616
subject(
1717
'Some text<span>Inline text</span>More text<div>Block content</div>Even more text',
18-
'<p>Some text<span>Inline text</span>More text</p><div>Block content</div><p>Even more text</p>'
18+
'<p>Some text<span>Inline text</span>More text</p><div>Block content</div><p>Even more text</p>',
1919
)
2020
})
2121

2222
it('should not create <p> tags for whitespace-only nodes', () => {
2323
subject(
2424
'<span>Inline text</span><span> </span><span>More text</span>',
25-
'<p><span>Inline text</span><span> </span><span>More text</span></p>'
25+
'<p><span>Inline text</span><span> </span><span>More text</span></p>',
2626
)
2727
})
2828

0 commit comments

Comments
 (0)