Skip to content

Commit

Permalink
parsing of HTML code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed Apr 3, 2024
1 parent 79d0c96 commit 78e3a57
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/modules/blocks/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function parseMessageBlocks(text: string, disableParsing: boolean, forceT

const regexPatterns = {
codeBlock: /`{3,}([\w\x20\\.+-_]+)?\n([\s\S]*?)(`{3,}\n?|$)/g,
htmlCodeBlock: /<!DOCTYPE html>([\s\S]*?)<\/html>/g,
svgBlock: /<svg (xmlns|width|viewBox)=([\s\S]*?)<\/svg>/g,
latexBlock: /\$\$([\s\S]*?)\$\$\n?/g,
latexBlock2: /\\\[\n([\s\S]*?)\n\s*\\]\n/g,
Expand Down Expand Up @@ -96,6 +97,12 @@ export function parseMessageBlocks(text: string, disableParsing: boolean, forceT
blocks.push({ type: 'code', blockTitle, blockCode, complete: blockEnd.startsWith('```') });
break;


case 'htmlCodeBlock':
const html: string = `<!DOCTYPE html>${match[1]}</html>`;
blocks.push({ type: 'code', blockTitle: 'html', blockCode: html, complete: true });
break;

case 'latexBlock':
case 'latexBlock2':
const latex: string = match[1];
Expand Down

0 comments on commit 78e3a57

Please sign in to comment.