Gathering detailed insights and metrics for @allegro/convert-description
Gathering detailed insights and metrics for @allegro/convert-description
Gathering detailed insights and metrics for @allegro/convert-description
Gathering detailed insights and metrics for @allegro/convert-description
npm install @allegro/convert-description
Typescript
Module System
Min. Node Version
Node Version
NPM Version
Fix running bin through npx
Published on 17 Dec 2024
Move sanitize-html to devDependencies
Published on 17 Dec 2024
Provide CLI
Published on 16 Dec 2024
Skip img tag with blank url
Published on 26 Aug 2024
Align the versioning with the internal releases
Published on 20 Aug 2024
Include a compiled code in a release
Published on 12 Aug 2024
JavaScript (100%)
Total Downloads
706
Last Day
2
Last Week
199
Last Month
217
Last Year
706
4 Stars
14 Commits
2 Branches
6 Contributors
Latest Version
0.5.4
Package Id
@allegro/convert-description@0.5.4
Unpacked Size
229.39 kB
Size
74.80 kB
File Count
6
NPM Version
10.9.0
Node Version
22.12.0
Publised On
17 Dec 2024
Cumulative downloads
Total Downloads
Last day
-50%
2
Compared to previous day
Last week
2,111.1%
199
Compared to previous week
Last month
1,042.1%
217
Compared to previous month
Last year
0%
706
Compared to previous year
25
A JavaScript library to convert HTML-rich offer & product descriptions into a format accepted by Allegro Rest API.
Provide means to ease the conversion of HTML-rich offer & product descriptions into a format accepted by Allegro Rest API. As such, the library covers basic functionality. Any client-specific behavior must be provided externally. The library can facilitate that through extensibility.
The library requires DOM API, which can be provided in two ways: either implicitly
as globals by the browser environment or explicitly as the parseToDOM
function in the Node.js environment (see
Usage section).
The following requirements apply to Node.js as a runtime or build environment.
1npm i @allegro/convert-description
For the Node.js runtime environment, include jsdom.
1npm i @allegro/convert-description jsdom
JavaScript code
1import { convertDescriptionToItems } from '@allegro/convert-description'; 2 3const description = ` 4 <div> 5 <div>test content</div> 6 <img src="/test_url" /> 7 </div> 8 `; 9 10const items = convertDescriptionToItems(description); 11 12console.log(JSON.stringify(items));
Code output
1[{"type":"TEXT","content":"<p>test content</p>"},{"type":"IMAGE","url":"/test_url"}]
For the Node.js runtime environment, pass the parseToDOM
function.
1import { convertDescriptionToItems } from '@allegro/convert-description'; 2import { JSDOM } from 'jsdom'; 3 4function parseToDOM(html) { 5 return new JSDOM(html); 6} 7 8const description = ` 9 <div> 10 <div>test content</div> 11 <img src="/test_url" /> 12 </div> 13 `; 14const items = convertDescriptionToItems(description, { parseToDOM }); 15 16console.log(JSON.stringify(items));
[!CAUTION] Any option to
convertDescriptionToItems
that is not mentioned in the documentation is subject to change. If you need anything more than the listed options, ask a question by opening an issue or contribute by creating a pull request.
1$ echo "<p>Hello World</p>" | npx @allegro/convert-description 2[{"type":"TEXT","content":"<p>Hello World</p>"}]
No vulnerabilities found.
No security vulnerabilities found.