markdown-loader icon indicating copy to clipboard operation
markdown-loader copied to clipboard

Quick fix to enable usage of Marker extensions

Open denis-migdal opened this issue 1 year ago • 0 comments
trafficstars

Quick fix to enable the usage of Marker extensions.

An example with marked-highlight :

// highlight
const { markedHighlight } = require("./../../example/node_modules/marked-highlight");
const hljs = require('./../../example/node_modules/highlight.js');

// inside Webpack rules :

{
		test: /\.md$/,
		use: [
            {
                /*loader: "html-loader",*/
                loader: 'file-loader',
			    options: { name: `[name].html` }
            },
            {
                loader: "markdown-loader",
                options: { // https://marked.js.org/using_advanced#options
                    options: {},
                    extensions: [
                        markedHighlight({
                            langPrefix: 'hljs language-',
                            highlight(code, lang, info) {
                                const language = hljs.getLanguage(lang) ? lang : 'plaintext';
                                return hljs.highlight(code, { language }).value;
                            }
                        })
                    ]
                },
            },
        ],
	}

denis-migdal avatar Jul 27 '24 10:07 denis-migdal