dn-scribe commited on
Commit
f80f550
·
unverified ·
1 Parent(s): d78c064

fix: render markdown

Browse files
Files changed (1) hide show
  1. app/templates/index.html +33 -13
app/templates/index.html CHANGED
@@ -4,26 +4,27 @@
4
  <title>CVE Report</title>
5
  <style>
6
  body {
7
- font-family: Arial, sans-serif; /* Use a more modern font */
8
  padding: 20px;
9
  background-color: #fafafa;
10
  }
11
  #output {
12
- white-space: normal; /* Allow normal text wrapping */
13
- background: #ffffff; /* Set a white background for better contrast */
14
  border: 1px solid #ddd;
15
  padding: 1em;
16
  min-height: 300px;
17
  overflow-y: auto;
18
- max-width: 800px; /* Set a reasonable max width for readability */
19
- margin: 20px auto; /* Center the content with some spacing */
20
- line-height: 1.6; /* Improve readability with better line spacing */
21
- font-size: 16px; /* Set a comfortable font size */
22
- color: #333; /* Use a dark gray color for text */
 
23
  }
24
  h2 {
25
- text-align: center; /* Center the header */
26
- color: #444; /* Use a slightly lighter color for the header */
27
  }
28
  </style>
29
  </head>
@@ -45,14 +46,33 @@
45
 
46
  evtSource.onmessage = (e) => {
47
  const markdownContent = e.data;
48
- markdownBuffer += markdownContent + "\n"; // Append to buffer with newline
49
- outputEl.innerHTML = marked.parse(markdownBuffer); // Render the entire buffer
50
  outputEl.scrollTop = outputEl.scrollHeight;
51
  };
52
 
53
- evtSource.onerror = () => {
 
54
  outputEl.innerHTML = "<p style='color: red;'>Error loading content. Please try again later.</p>";
55
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  </script>
57
 
58
  </body>
 
4
  <title>CVE Report</title>
5
  <style>
6
  body {
7
+ font-family: Arial, sans-serif;
8
  padding: 20px;
9
  background-color: #fafafa;
10
  }
11
  #output {
12
+ white-space: normal;
13
+ background: #ffffff;
14
  border: 1px solid #ddd;
15
  padding: 1em;
16
  min-height: 300px;
17
  overflow-y: auto;
18
+ max-width: 800px;
19
+ margin: 20px auto;
20
+ line-height: 1.6;
21
+ font-size: 16px;
22
+ color: #333;
23
+ text-align: left; /* Ensure text and headers are left-aligned */
24
  }
25
  h2 {
26
+ text-align: left; /* Left-align the header */
27
+ color: #444;
28
  }
29
  </style>
30
  </head>
 
46
 
47
  evtSource.onmessage = (e) => {
48
  const markdownContent = e.data;
49
+ markdownBuffer += markdownContent + "\n";
50
+ outputEl.innerHTML = marked.parse(markdownBuffer);
51
  outputEl.scrollTop = outputEl.scrollHeight;
52
  };
53
 
54
+ evtSource.onerror = (e) => {
55
+ console.error("EventSource error:", e);
56
  outputEl.innerHTML = "<p style='color: red;'>Error loading content. Please try again later.</p>";
57
  };
58
+
59
+ // Fallback for refreshing to load Markdown from a file
60
+ if (refresh) {
61
+ fetch(`/report?cve_id=${cveId}`)
62
+ .then((response) => {
63
+ if (!response.ok) {
64
+ throw new Error(`HTTP error! status: ${response.status}`);
65
+ }
66
+ return response.text();
67
+ })
68
+ .then((markdownContent) => {
69
+ outputEl.innerHTML = marked.parse(markdownContent);
70
+ })
71
+ .catch((error) => {
72
+ console.error("Fetch error:", error);
73
+ outputEl.innerHTML = "<p style='color: red;'>Error loading content. Please try again later.</p>";
74
+ });
75
+ }
76
  </script>
77
 
78
  </body>