diff --git a/src/utilities/process-readme.js b/src/utilities/process-readme.js index 20e6a8ff3bfe..896acdd3ed61 100644 --- a/src/utilities/process-readme.js +++ b/src/utilities/process-readme.js @@ -94,7 +94,7 @@ module.exports = function processREADME(body, options = {}) { let processingString = body // remove items other than paragraphs in div[align="center"] // e.g., logo, title and so on. - .replace(/[^]*?
([^]*?)<\/div>/, (match, content) => { + .replace(/[^]*?
([^]*)<\/div>/, (match, content) => { let parsed = content.match(/

\s+([^]*?)\s+<\/?p>/); return parsed ? parsed[1] : ''; }) diff --git a/src/utilities/process-readme.test.js b/src/utilities/process-readme.test.js index 0dae2439f6ff..5fa0bb19a86a 100644 --- a/src/utilities/process-readme.test.js +++ b/src/utilities/process-readme.test.js @@ -59,4 +59,35 @@ describe('processReadme', () => {

`; expect(processReadme(loaderMDData)).toEqual(''); }); + + it('should clean up div[align="center"] with nested dev[align="center"]', () => { + // see https://raw.githubusercontent.com/webpack-contrib/postcss-loader/master/README.md + const loaderMDData = ` +
+ PostCSS Logo + + + +
+ + Sponsored by Evil Martians + +
+
`; + expect(processReadme(loaderMDData)).toEqual(''); + }); });