Skip to content

Commit 8996ced

Browse files
committed
Added <div> support to renderHTML()(fixes KudoAI/chatgpt.js#756) ↞ [auto-sync from https://github.com/KudoAI/chatgpt.js]
1 parent 788579b commit 8996ced

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

chatgpt.js/src/chatgpt.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,11 +1590,14 @@ const chatgpt = {
15901590

15911591
renderHTML(node) {
15921592
if (!chatgpt._validateEnv({ allowed: 'frontend' })) return
1593-
const reTags = /<([a-z\d]+)\b([^>]*)>([\s\S]*?)<\/\1>/g,
1594-
reAttrs = /(\S+)=(?:(["'])([\s\S]*?)\2|([^\s>'"=]+))/g,
1595-
nodeContent = node.childNodes,
1596-
allowedTags = new Set(['a', 'b', 'i', 'em', 'strong', 'br', 'span', 'p', 'code', 'pre', 'ul', 'ol', 'li']),
1597-
allowedAttrs = { a: ['href', 'target', 'rel'], span: ['class', 'style'], code: ['class'] }
1593+
1594+
const reTags = /<([a-z\d]+)\b([^>]*)>([\s\S]*?)<\/\1>/g
1595+
const reAttrs = /(\S+)=(?:(["'])([\s\S]*?)\2|([^\s>'"=]+))/g
1596+
const nodeContent = node.childNodes
1597+
const allowedTags = new Set([
1598+
'a', 'b', 'i', 'em', 'strong', 'br', 'div', 'span', 'p', 'code', 'pre', 'ul', 'ol', 'li'])
1599+
const allowedAttrs = {
1600+
a: ['href', 'target', 'rel'], div: ['class', 'style'], span: ['class', 'style'], code: ['class'] }
15981601

15991602
// Preserve consecutive spaces + line breaks
16001603
if (!chatgpt.renderHTML.preWrapSet) {

0 commit comments

Comments
 (0)