
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
markup-color-extractor
Advanced tools
Extract colors from HTML and XML. This library can detect all of the color types supported by TinyColor.
opt
)Extract colors from a buffer
opt
- An options object
buffer
- A Buffer containing markuperr
, array colors
) cb
- A function to be executed after the colors are extractedunique
- (Optional) If true
, the color array will not contain duplicates (Default true
)text
- (Optional) If true
, will search element inner text for colorsattributes
- (Optional) If true
, will search all element attributes for colors, or if an array, will search only the attributes listed in the arrayExample
fs.readFile(path.join(__dirname, 'colors.xml'), function(err, data) {
if (err) { throw err; }
extractColors.from.buffer({
buffer: data,
attributes: true,
text: true,
cb: function(err, colors) {
if (err) { throw err; }
console.log(colors);
}
});
});
opt
)Extract colors from a string
opt
- An options object
string
- A string containing markuperr
, array colors
) cb
- A function to be executed after the colors are extractedunique
- (Optional) If true
, the color array will not contain duplicates (Default true
)text
- (Optional) If true
, will search element inner text for colorsattributes
- (Optional) If true
, will search all element attributes for colors, or if an array, will search only the attributes listed in the arrayExample
extractColors.from.string({
string: '<color value="#E0162B">#0052A5</color>',
text: true,
attributes: ['value'],
cb: function(err, colors) {
if (err) { throw err; }
console.log(colors);
}
});
opt
)Extract colors from a file
opt
- An options object
file
- A path to a file containing markuperr
, array colors
) cb
- A function to be executed after the colors are extractedunique
- (Optional) If true
, the color array will not contain duplicates (Default true
)text
- (Optional) If true
, will search element inner text for colorsattributes
- (Optional) If true
, will search all element attributes for colors, or if an array, will search only the attributes listed in the arrayExample
extractColors.from.file({
file: path.join(__dirname, 'colors.xml'),
attributes: true,
text: true,
cb: function(err, colors) {
if (err) { throw err; }
console.log(colors);
}
});
opt
)Extract colors from a url
opt
- An options object
url
- A url to a file containing markuperr
, array colors
) cb
- A function to be executed after the colors are extractedunique
- (Optional) If true
, the color array will not contain duplicates (Default true
)text
- (Optional) If true
, will search element inner text for colorsattributes
- (Optional) If true
, will search all element attributes for colors, or if an array, will search only the attributes listed in the arrayExample
extractColors.from.url({
url: 'http://site.com/colors.html',
attributes: true,
text: true,
cb: function(err, colors) {
if (err) { throw err; }
console.log(colors);
}
});
You may also supply any of the htmlparser2 parser options in opt
for all of the methods listed above.
npm install markup-color-extractor
Before running the tests, Mocha must be installed:
npm install -g mocha
To run the tests:
npm test
FAQs
Extract colors from markup (XML and HTML)
We found that markup-color-extractor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.