From c25fd015a690b44bd87596171cef5b7befa1e0ad Mon Sep 17 00:00:00 2001 From: stevending1st <1139274654@qq.com> Date: Thu, 17 Jun 2021 15:20:13 +0800 Subject: [PATCH] add and add test --- dist/index.js | 3 +- src/__test__/utilities.test.js | 93 ++++++++++++++++++++++------------ src/utilities.js | 3 +- 3 files changed, 66 insertions(+), 33 deletions(-) diff --git a/dist/index.js b/dist/index.js index 4e4c979..58dccff 100644 --- a/dist/index.js +++ b/dist/index.js @@ -45312,11 +45312,12 @@ exports.HTMLtoMarkdown = (html) => return reject(Err_DOMWrong); // full image - let fullImage = $('.post-full-image > img') || '', + let fullImage = $('.post-full-image > picture > img') || '', fullImageURL; // Is there a full image if (fullImage) { fullImageURL = fullImage.attr('src'); + // Whether the src of the full image is empty if (!fullImageURL) return reject(Err_DOMWrong); else { diff --git a/src/__test__/utilities.test.js b/src/__test__/utilities.test.js index 2eeac12..782f9e1 100644 --- a/src/__test__/utilities.test.js +++ b/src/__test__/utilities.test.js @@ -178,7 +178,9 @@ describe("5. test HTMLtoMarkdown(Write content to file).", () => {

testexample post-full-title

- postFullImage + + postFullImage +
@@ -209,7 +211,7 @@ describe("5. test HTMLtoMarkdown(Write content to file).", () => {
Zubin Pratap -
+

authorName

@@ -274,7 +276,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -283,7 +287,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

@@ -322,7 +326,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -331,7 +337,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

@@ -372,7 +378,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

- postFullImage + + postFullImage +
@@ -382,7 +390,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

@@ -414,7 +422,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
- postFullImage + + postFullImage +
@@ -424,7 +434,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

@@ -457,7 +467,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -467,7 +479,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

@@ -500,7 +512,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -510,7 +524,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

@@ -543,7 +557,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -553,7 +569,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

@@ -586,7 +602,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -596,7 +614,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

@@ -629,7 +647,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -639,7 +659,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+
@@ -671,7 +691,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -681,7 +703,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

@@ -714,7 +736,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -724,7 +748,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

@@ -757,7 +781,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -767,7 +793,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

@@ -800,7 +826,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -809,7 +837,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

@@ -842,7 +870,9 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

- postFullImage + + postFullImage +
@@ -851,7 +881,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

@@ -884,6 +914,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

testexample post-full-title

+
@@ -892,7 +923,7 @@ pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
Zubin Pratap -
+

authorName

diff --git a/src/utilities.js b/src/utilities.js index 3a5679b..c58c8c3 100644 --- a/src/utilities.js +++ b/src/utilities.js @@ -91,11 +91,12 @@ exports.HTMLtoMarkdown = (html) => return reject(Err_DOMWrong); // full image - let fullImage = $('.post-full-image > img') || '', + let fullImage = $('.post-full-image > picture > img') || '', fullImageURL; // Is there a full image if (fullImage) { fullImageURL = fullImage.attr('src'); + // Whether the src of the full image is empty if (!fullImageURL) return reject(Err_DOMWrong); else {