Browse Source

fix support single-quoted classes in KP markdown parsing

Allow kp markdown source/container matching to work with both single and double quoted class attributes so markdown conversion is not skipped.

Made-with: Cursor
yemeishu 2 weeks ago
parent
commit
c162b9b686
1 changed files with 2 additions and 2 deletions
  1. 2 2
      app/Services/ExamPdfExportService.php

+ 2 - 2
app/Services/ExamPdfExportService.php

@@ -1933,9 +1933,9 @@ class ExamPdfExportService
         $parser = new \Michelf\MarkdownExtra;
 
         return preg_replace_callback(
-            '/<div[^>]*class="[^"]*\bkp-markdown-source\b[^"]*"[^>]*>([\s\S]*?)<\/div>(?:\s*<div[^>]*class="[^"]*\bkp-markdown-container\b[^"]*"[^>]*>[\s\S]*?<\/div>)?/i',
+            '/<div[^>]*class=(["\'])[^"\']*\bkp-markdown-source\b[^"\']*\1[^>]*>([\s\S]*?)<\/div>(?:\s*<div[^>]*class=(["\'])[^"\']*\bkp-markdown-container\b[^"\']*\3[^>]*>[\s\S]*?<\/div>)?/i',
             function ($matches) use ($parser) {
-                $markdown = html_entity_decode(trim($matches[1]), ENT_QUOTES, 'UTF-8');
+                $markdown = html_entity_decode(trim($matches[2]), ENT_QUOTES, 'UTF-8');
                 $rendered = $parser->transform($markdown);
 
                 return '<div class="kp-markdown-container kp-markdown-content">'.$rendered.'</div>';