fix: render markdown
Browse files- 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;
|
| 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 |
}
|
| 24 |
h2 {
|
| 25 |
-
text-align:
|
| 26 |
-
color: #444;
|
| 27 |
}
|
| 28 |
</style>
|
| 29 |
</head>
|
|
@@ -45,14 +46,33 @@
|
|
| 45 |
|
| 46 |
evtSource.onmessage = (e) => {
|
| 47 |
const markdownContent = e.data;
|
| 48 |
-
markdownBuffer += markdownContent + "\n";
|
| 49 |
-
outputEl.innerHTML = marked.parse(markdownBuffer);
|
| 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>
|