
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
md2js-loader
Advanced tools
Exports Markdown to javascript instructions. Create javascript functions from Markdown templates.
Exports Markdown to javascript instructions. Create javascript functions from Markdown templates.
npm i -D md2js-loader
Add the md2js-loader to your webpack.config.js.
{
test: /\.(markdown|md)$/,
use: {
loader: 'md2js-loader',
options: {}
}
}
Now, simply import/require any markdown files. For example:
Example
=======
- 1
- 2
- 3
- 4
const createList = require('./templates/list.markdown');
document.body.appendChild(createList());
this will be converted to the following javascript:
function createNode() {
var container = document.createDocumentFragment();
var e_0 = document.createElement("div");
var e_1 = document.createElement("h1");
e_1.setAttribute("id", "example");
e_1.appendChild(document.createTextNode("Example"));
e_0.appendChild(e_1);
var e_2 = document.createElement("ul");
var e_3 = document.createElement("li");
e_3.appendChild(document.createTextNode("1"));
e_2.appendChild(e_3);
var e_4 = document.createElement("li");
e_4.appendChild(document.createTextNode("2"));
e_2.appendChild(e_4);
var e_5 = document.createElement("li");
e_5.appendChild(document.createTextNode("3"));
e_2.appendChild(e_5);
var e_6 = document.createElement("li");
e_6.appendChild(document.createTextNode("4"));
e_2.appendChild(e_6);
e_0.appendChild(e_2);
container.appendChild(e_0);
return container;
}
The loader will optimize this code by injecting the following base code into your bundle:
module.exports = {
document_createDocumentFragment: () => {
return document.createDocumentFragment();
},
document_createElement: name => {
return document.createElement(name);
},
document_createTextNode: text => {
return document.createTextNode(text);
},
appendChild: (parent, child) => {
parent.appendChild(child);
},
setAttribute: (elem, key, value) => {
elem.setAttribute(key, value);
}
};
This will enable the compiler to name mangle these function calls.
FAQs
Exports Markdown to javascript instructions. Create javascript functions from Markdown templates.
The npm package md2js-loader receives a total of 1 weekly downloads. As such, md2js-loader popularity was classified as not popular.
We found that md2js-loader 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.