Skip to content

Commit 557e4e9

Browse files
committed
fix regular expression to contain nested div[align="center"]
1 parent 8a97840 commit 557e4e9

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/utilities/process-readme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ module.exports = function processREADME(body, options = {}) {
9494
let processingString = body
9595
// remove items other than paragraphs in div[align="center"]
9696
// e.g., logo, title and so on.
97-
.replace(/[^]*?<div align="center">([^]*?)<\/div>/, (match, content) => {
97+
.replace(/[^]*?<div align="center">([^]*)<\/div>/, (match, content) => {
9898
let parsed = content.match(/<p>\s+([^]*?)\s+<\/?p>/);
9999
return parsed ? parsed[1] : '';
100100
})

src/utilities/process-readme.test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,35 @@ describe('processReadme', () => {
5959
</div>`;
6060
expect(processReadme(loaderMDData)).toEqual('');
6161
});
62+
63+
it('should clean up div[align="center"] with nested dev[align="center"]', () => {
64+
// see https://raw.githubusercontent.com/webpack-contrib/postcss-loader/master/README.md
65+
const loaderMDData = `
66+
<div align="center">
67+
<img
68+
width="180"
69+
height="180"
70+
hspace="10"
71+
alt="PostCSS Logo"
72+
src="https://api.postcss.org/logo.svg">
73+
<a href="https://github.com/webpack/webpack">
74+
<img
75+
width="200"
76+
height="200"
77+
hspace="10"
78+
src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon.svg">
79+
</a>
80+
<div align="center">
81+
<a href="https://evilmartians.com/?utm_source=postcss">
82+
<img
83+
src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
84+
alt="Sponsored by Evil Martians"
85+
width="236"
86+
height="54"
87+
vspace="10">
88+
</a>
89+
</div>
90+
</div>`;
91+
expect(processReadme(loaderMDData)).toEqual('');
92+
});
6293
});

0 commit comments

Comments
 (0)