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
46.9
Supply Chain
90.8
Quality
79.9
Maintenance
100
Vulnerability
86.9
License
Fix running bin through npx
Updated on Dec 17, 2024
Move sanitize-html to devDependencies
Updated on Dec 17, 2024
Provide CLI
Updated on Dec 16, 2024
Skip img tag with blank url
Updated on Aug 26, 2024
Align the versioning with the internal releases
Updated on Aug 20, 2024
Include a compiled code in a release
Updated on Aug 12, 2024
JavaScript (100%)
Total Downloads
1,072
Last Day
1
Last Week
3
Last Month
50
Last Year
1,072
Apache-2.0 License
4 Stars
14 Commits
3 Branches
6 Contributors
Updated on May 27, 2025
Minified
Minified + Gzipped
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
Published on
Dec 17, 2024
Cumulative downloads
Total Downloads
Last Day
-50%
1
Compared to previous day
Last Week
-72.7%
3
Compared to previous week
Last Month
-39%
50
Compared to previous month
Last Year
0%
1,072
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.