Skip to content

Commit

Permalink
feat: allow from property (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
kptdobe committed Feb 6, 2023
1 parent cd2d280 commit 91f9681
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/importer/HTML2x.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ async function html2x(

if (result.element) {
extra.html = result.element.outerHTML;
} else if (result.from) {
extra.from = result.from;
}

if (result.report) {
Expand Down Expand Up @@ -190,6 +192,10 @@ async function html2x(
res.html = pir.extra.html;
}

if (pir.extra.from) {
res.from = pir.extra.from;
}

if (pir.extra.report) {
res.report = pir.extra.report;
}
Expand Down
2 changes: 2 additions & 0 deletions test/importers/HTML2x.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ describe('html2md tests', () => {
const out = await html2md('https://www.sample.com/page.html', '<html><body><h1>Hello World</h1></body></html>', {
transform: () => [{
path: '/my-custom-path-p1',
from: 'https://www.sample.com/page.html',
report: {
custom: 'A custom property',
customArray: ['a', 'b', 'c'],
Expand All @@ -253,6 +254,7 @@ describe('html2md tests', () => {
strictEqual(out.md, undefined);
strictEqual(out.docx, undefined);
strictEqual(out.path, '/my-custom-path-p1');
strictEqual(out.from, 'https://www.sample.com/page.html');
ok(out.report);
strictEqual(out.report.custom, 'A custom property');
deepStrictEqual(out.report.customArray, ['a', 'b', 'c']);
Expand Down

0 comments on commit 91f9681

Please sign in to comment.