
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
An HTML to Textile converter written in JavaScript. This code is based on the original markdown converter by dom christie.
The API is as follows:
toTextile(stringOfHTML, options);
Download the compiled script located at dist/to-textile.min.js,
<script src="PATH/TO/to-textile.min.js"></script>
<script>toTextile('<h1>Hello world!</h1>')</script>
Install the to-textile module:
$ npm install to-textile
Then you can use it like below:
var toTextile = require('to-textile');
toTextile('<h1>Hello world!</h1>');
converters (array)to-textile can be extended by passing in an array of converters to the options object:
toTextile(stringOfHTML, { converters: [converter1, converter2, …] });
A converter object consists of a filter, and a replacement. This example from the source replaces code elements:
{
filter: 'code',
replacement: function(content) {
return '`' + content + '`';
}
}
filter (string|array|function)The filter property determines whether or not an element should be replaced. DOM nodes can be selected simply by filtering by tag name, with strings or with arrays of strings:
filter: 'p' will select p elementsfilter: ['em', 'i'] will select em or i elementsAlternatively, the filter can be a function that returns a boolean depending on whether a given node should be replaced. The function is passed a DOM node as its only argument. For example, the following will match any span element with an italic font style:
filter: function (node) {
return node.nodeName === 'SPAN' && /italic/i.test(node.style.fontStyle);
}
replacement (function)The replacement function determines how an element should be converted. It should return the textile string for a given node. The function is passed the node’s content, as well as the node itself (used in more complex conversions). It is called in the context of toTextile, and therefore has access to the methods detailed below.
The following converter replaces heading elements (h1-h6):
{
filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
replacement: function(innerHTML, node) {
var hLevel = node.tagName.charAt(1);
var hPrefix = '';
for(var i = 0; i < hLevel; i++) {
hPrefix += '#';
}
return '\n' + hPrefix + ' ' + innerHTML + '\n\n';
}
}
gfm (boolean)to-textile has beta support for GitHub flavored textile (GFM). Set the gfm option to true:
toTextile('<del>Hello world!</del>', { gfm: true });
The following methods can be called on the toTextile object.
isBlock(node)Returns true/false depending on whether the element is block level.
isVoid(node)Returns true/false depending on whether the element is void.
outer(node)Returns the content of the node along with the element itself.
First make sure you have node.js/npm installed, then:
$ npm install --dev
Automatically browserify the module when source files change by running:
$ npm start
To run the tests in the browser, open test/index.html.
To run in node.js:
$ npm test
Thanks to Dom Christie for the original markdown implementation.
to-textile is copyright © 2017+ cmroanirgo and released under the MIT license.
FAQs
An HTML to Textile converter
The npm package to-textile receives a total of 10 weekly downloads. As such, to-textile popularity was classified as not popular.
We found that to-textile 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.