| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- {{-- 知识点讲解完整模板 --}}
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <title>知识点讲解</title>
- <link rel="stylesheet" href="/css/katex/katex.min.css">
- @include('pdf.partials.kp-explain-styles')
- @include('pdf.partials.katex-scripts')
- <script src="/js/math-render.js"></script>
- </head>
- <body>
- <div class="kp-explain">
- <div class="kp-explain-header">
- <div class="kp-explain-title">知识点讲解</div>
- <div class="kp-explain-subtitle">
- 本章节用于梳理本卷涉及的知识点,帮助学生在做题前完成预习/复盘。
- </div>
- </div>
- @if(empty($knowledgePoints))
- <div class="kp-empty">暂无知识点数据</div>
- @else
- <div class="kp-list">
- @foreach($knowledgePoints as $index => $kp)
- <div class="kp-section">
- <div class="kp-section-head">
- <div class="kp-section-name">{{ $loop->iteration }}、{{ $kp['kp_name'] ?? ($kp['kp_code'] ?? '未命名知识点') }}</div>
- </div>
- <div class="kp-section-body">
- @if(!empty($kp['explanation']))
- {{-- 解析 ## 标题分段:## 知识点 和 ## 知识点应用 --}}
- @php
- $explanation = $kp['explanation'];
- // 提取 ## 知识点 部分
- preg_match('/##\s*知识点\s*\n([\s\S]*?)(?=##\s*知识点应用|$)/u', $explanation, $knowledgeMatch);
- $knowledgeContent = isset($knowledgeMatch[1]) ? trim($knowledgeMatch[1]) : '';
- // 提取 ## 知识点应用 部分
- preg_match('/##\s*知识点应用\s*\n([\s\S]*)/u', $explanation, $applicationMatch);
- $applicationContent = isset($applicationMatch[1]) ? trim($applicationMatch[1]) : '';
- @endphp
- @if(!empty($knowledgeContent))
- <div class="kp-block">
- <div class="kp-block-title"><span class="check">✓</span>知识点</div>
- <div class="kp-markdown-content">{!! \App\Services\MathFormulaProcessor::processFormulas($knowledgeContent) !!}</div>
- </div>
- @endif
- @if(!empty($applicationContent))
- <div class="kp-block">
- <div class="kp-block-title"><span class="check">✓</span>知识点应用</div>
- <div class="kp-markdown-content">{!! \App\Services\MathFormulaProcessor::processFormulas($applicationContent) !!}</div>
- </div>
- @endif
- @endif
- </div>
- </div>
- @endforeach
- </div>
- @endif
- </div>
- <script>
- // 确保数学公式渲染系统已初始化
- document.addEventListener('DOMContentLoaded', function() {
- // 延迟渲染,确保所有脚本加载完成
- setTimeout(function() {
- // 渲染 kp-markdown-content 中的公式
- document.querySelectorAll('.kp-markdown-content').forEach(function(el) {
- if (typeof window.renderMathElement === 'function' && el.dataset.rendered !== 'true') {
- window.renderMathElement(el);
- }
- });
-
- // 如果 MathRender 系统可用,使用它
- if (typeof window.MathRender !== 'undefined') {
- // 临时修改 selector 以渲染 kp-markdown-content
- var originalSelector = window.MathRenderConfig.selector;
- window.MathRenderConfig.selector = '.kp-markdown-content';
- window.MathRender.renderAll();
- window.MathRenderConfig.selector = originalSelector;
- }
-
- // 触发自定义事件,让其他渲染系统也能响应
- document.dispatchEvent(new CustomEvent('math:render'));
- }, 100);
-
- // 再次尝试渲染,处理可能的异步加载情况
- setTimeout(function() {
- document.querySelectorAll('.kp-markdown-content').forEach(function(el) {
- if (typeof window.renderMathElement === 'function' && el.dataset.rendered !== 'true') {
- window.renderMathElement(el);
- }
- });
- }, 500);
- });
- </script>
- </body>
- </html>
|