1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+
4+ < head >
5+ < meta charset ="UTF-8 ">
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7+ < title > Markdown</ title >
8+ < link href ="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4v5QBAARLAaU/Dnq2AAAAAElFTkSuQmCC " rel ="icon " type ="image/x-icon " />
9+ < script src ="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js "> </ script >
10+
11+ < style >
12+ body {
13+ font-family : Arial, sans-serif;
14+ background-color : # 282c34 ;
15+ color : white;
16+ padding : 20px ;
17+ max-width : 800px ;
18+ margin : 0 auto;
19+ line-height : 1.6 ;
20+ }
21+
22+ h1 , h2 , h3 , h4 , h5 , h6 {
23+ color : # 61dafb ;
24+ margin-top : 24px ;
25+ margin-bottom : 16px ;
26+ }
27+
28+ h1 {
29+ font-size : 2em ;
30+ border-bottom : 1px solid # 444 ;
31+ padding-bottom : 0.3em ;
32+ }
33+
34+ h2 {
35+ font-size : 1.5em ;
36+ border-bottom : 1px solid # 444 ;
37+ padding-bottom : 0.3em ;
38+ }
39+
40+ a {
41+ color : # 9cdcfe ;
42+ text-decoration : none;
43+ }
44+
45+ a : hover {
46+ text-decoration : underline;
47+ }
48+
49+ code {
50+ font-family : 'Courier New' , Courier, monospace;
51+ background-color : # 1e1e1e ;
52+ padding : 0.2em 0.4em ;
53+ border-radius : 3px ;
54+ font-size : 85% ;
55+ }
56+
57+ pre {
58+ background-color : # 1e1e1e ;
59+ padding : 16px ;
60+ border-radius : 5px ;
61+ overflow-x : auto;
62+ margin : 16px 0 ;
63+ }
64+
65+ pre code {
66+ padding : 0 ;
67+ background-color : transparent;
68+ }
69+
70+ blockquote {
71+ padding : 0 1em ;
72+ color : # aaa ;
73+ border-left : 0.25em solid # 444 ;
74+ }
75+
76+ table {
77+ border-collapse : collapse;
78+ width : 100% ;
79+ margin : 16px 0 ;
80+ }
81+
82+ table th , table td {
83+ border : 1px solid # 444 ;
84+ padding : 8px 12px ;
85+ }
86+
87+ table th {
88+ background-color : # 1e1e1e ;
89+ }
90+
91+ img {
92+ max-width : 100% ;
93+ }
94+
95+ ul , ol {
96+ padding-left : 2em ;
97+ }
98+
99+ strong {
100+ color : # e5c07b ;
101+ }
102+
103+ em {
104+ color : # c678dd ;
105+ }
106+
107+ .mermaid {
108+ background-color : # 1e1e1e ;
109+ padding : 16px ;
110+ border-radius : 5px ;
111+ margin : 16px 0 ;
112+ text-align : center;
113+ }
114+
115+ .language-mermaid {
116+ display : none;
117+ }
118+
119+ .mermaid-container {
120+ background-color : # 1e1e1e ;
121+ padding : 16px ;
122+ border-radius : 5px ;
123+ margin : 16px 0 ;
124+ text-align : center;
125+ }
126+ </ style >
127+ </ head >
128+
129+ < body >
130+ < div class ="markdown-content ">
131+ {{ rendered_markdown|safe }}
132+ </ div >
133+
134+ < script >
135+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
136+ // Configure mermaid
137+ mermaid . initialize ( {
138+ theme : 'dark' ,
139+ securityLevel : 'loose' ,
140+ fontFamily : 'monospace' ,
141+ startOnLoad : false
142+ } ) ;
143+
144+ // Find all pre elements
145+ const preElements = document . querySelectorAll ( 'pre' ) ;
146+ preElements . forEach ( ( preElement , index ) => {
147+ // Get the code element inside
148+ const codeElement = preElement . querySelector ( 'code' ) ;
149+ if ( ! codeElement ) return ;
150+
151+ // Check if it's a mermaid block
152+ // First try the class
153+ const isMermaid = codeElement . classList . contains ( 'language-mermaid' ) ;
154+ // Or check if the first line says mermaid
155+ const firstLine = codeElement . textContent . trim ( ) . split ( '\n' ) [ 0 ] . trim ( ) ;
156+ const startsWithMermaid = firstLine === 'mermaid' ||
157+ firstLine === 'graph' ||
158+ firstLine === 'sequenceDiagram' ||
159+ firstLine . startsWith ( 'flowchart' ) ||
160+ firstLine === 'gantt' ||
161+ firstLine === 'classDiagram' ;
162+
163+ if ( isMermaid || startsWithMermaid ) {
164+ // Get the diagram code
165+ let diagramCode = codeElement . textContent ;
166+
167+ // Create a div for the mermaid diagram
168+ const mermaidDiv = document . createElement ( 'div' ) ;
169+ mermaidDiv . className = 'mermaid-container' ;
170+ mermaidDiv . id = 'mermaid-diagram-' + index ;
171+
172+ // Replace the pre element with our mermaid container
173+ preElement . parentNode . replaceChild ( mermaidDiv , preElement ) ;
174+
175+ // Create a div with the mermaid class
176+ const mermaidContentDiv = document . createElement ( 'div' ) ;
177+ mermaidContentDiv . className = 'mermaid' ;
178+ mermaidContentDiv . textContent = diagramCode ;
179+ mermaidDiv . appendChild ( mermaidContentDiv ) ;
180+
181+ // Let mermaid process it
182+ try {
183+ window . setTimeout ( ( ) => {
184+ mermaid . init ( undefined , mermaidContentDiv ) ;
185+ } , 0 ) ;
186+ } catch ( error ) {
187+ console . error ( 'Error processing diagram:' , error ) ;
188+ mermaidDiv . innerHTML = '<div class="error">Error processing diagram</div>' ;
189+ }
190+ }
191+ } ) ;
192+ } ) ;
193+ </ script >
194+ </ body >
195+
196+ </ html >
0 commit comments