parcel-plugin-markdown
parcel-plugin-markdown copied to clipboard
Added support for renderer method overrides
Parcel's getConfig
method clones the imported config object by default.
For this the clone library is used which does not copy over overridden methods in class instances.
This is relevant because of the following use-case:
// marked.config.js
const marked = require("marked");
const renderer = new marked.Renderer();
// E.g. override the link method to build custom link tags:
renderer.link = function(href, title, text) {
return `<a href="${href}" target="_blank">My link: ${text}</a>`;
}
module.exports = { renderer };
The cloning procedure breaks such configurations; in the example the custom link
method would not be used. This PR fixes the problem by simply not creating a clone which afaik should not break any existing code since marked configs are static and not affected by side-effects.