forked from snxraven/ravenscott-blog
update AI page
This commit is contained in:
parent
4ece2a9461
commit
267f68c646
@ -413,7 +413,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Converts the HTML content of the response to Markdown
|
||||
// Converts the HTML content of the response to Markdown, including language identifier
|
||||
function convertToMarkdown(element) {
|
||||
let markdown = '';
|
||||
const nodes = element.childNodes;
|
||||
@ -422,8 +422,13 @@
|
||||
if (node.nodeName === 'P') {
|
||||
markdown += `${node.innerText}\n\n`;
|
||||
} else if (node.nodeName === 'PRE') {
|
||||
const codeBlock = node.querySelector('code').innerText;
|
||||
markdown += `\`\`\`\n${codeBlock}\n\`\`\`\n\n`;
|
||||
const codeBlock = node.querySelector('code');
|
||||
const languageClass = codeBlock.className.match(/language-(\w+)/); // Extract language from class if available
|
||||
const language = languageClass ? languageClass[1] : ''; // Default to empty if no language found
|
||||
const codeText = codeBlock.innerText;
|
||||
|
||||
// Add language identifier to the Markdown code block
|
||||
markdown += `\`\`\`${language}\n${codeText}\n\`\`\`\n\n`;
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user