Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
metalsmith-pure-text
Advanced tools
A Metalsmith plugin for extracting text from source files using textract.
A Metalsmith plugin that extracts plain text without HTML tags, Markdown syntax, etc.
It acts as a wrapper for textract and uses its capabilities for handling different file formats.
npm install metalsmith-pure-text
The plugin takes an object containing different textract options - please look them up at textracts GitHub repository.
Additionally, some custom options are possible:
It can be configured to filter specific file suffixes by providing a pattern
option:
{
"pattern": "**/*.html" // string for one pattern only, array for multiple patterns
}
The outcome may be modified to contain only uppercase or lowercase letters. This can be done by adding only one key to the configuration:
{
// either:
"lowerCase": true
// or:
"upperCase": true
}
Usage is possible via JavaScript API and via Metalsmith CLI:
Pass the plugin to the Metalsmith instance using its .use()
function:
const metalsmith = require('metalsmith');
const pureText = require('metalsmith-pure-text');
metalsmith.use(pureText({
pattern: ['**/*.html'], // The globbing pattern you want to use. Single pattern also in array.
preserveLineBreaks: true, // textract option: preserve line breaks in extracted text.
// (...)
}));
Similar to the JavaScript API, the plugin may be used as follows:
{
"plugins": {
"metalsmith-pure-text": {
"pattern": ["**/*.html"],
"preserveLineBreaks": true
}
}
}
After the text extraction is done, the outcome is stored in the text
property of the respective file object, so one may be using it in templates similar like this (handlebars-example):
So you want to see the pure text contents of your file?
Here they are:
<pre>
{{text}}
</pre>
Please report any bugs or issues to the issues section.
Contributors welcome!
Please fork this repository, open a pull request and drop me a line on twitter.
MIT
lowerCase
/upperCase
functionality, removed whitespace from text outcome.FAQs
A Metalsmith plugin for extracting text from source files using textract.
The npm package metalsmith-pure-text receives a total of 3 weekly downloads. As such, metalsmith-pure-text popularity was classified as not popular.
We found that metalsmith-pure-text 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.