Skip to content

Commit 2958db5

Browse files
authored
fix: allow attributes on paragraphs with tweets
The old reg ex is only capturing `<p>` elements if those elements have no attribute set (eg `class` or `id`). This PR expands the reg ex to allow any attributes to be present. Demo on regexr: https://regexr.com/6v8ih
1 parent 8320882 commit 2958db5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

twitter.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ async function getStyles() {
309309
const asyncReplace = require('string-replace-async')
310310

311311
async function autoEmbedTweets(content, outputPath, options) {
312-
// https://regexr.com/5c39d
313-
let findTweets = /<p>(<a href=")?(https:\/\/twitter.com\/[^/]+\/status\/([0-9]+))(">\2<\/a>)?<\/p>/g
312+
// https://regexr.com/6v8ih
313+
let findTweets = /<p ?.*>(<a href=")?(https:\/\/twitter.com\/[^/]+\/status\/([0-9]+))(">\2<\/a>)?<\/p>/g
314314
return await asyncReplace(content, findTweets, async(match, p1, p2, p3) => {
315315
return await getTweet(p3, options)
316316
})
317-
}
317+
}

0 commit comments

Comments
 (0)