Skip to content

Commit e96197c

Browse files
committed
Markdown addition minor bug fix
1 parent a68d474 commit e96197c

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

codriver/frontend/script.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ function addAssistantMessage(response) {
5454
assistantContainer.classList.add("assistant-message-container");
5555

5656
const assistantMessage = document.createElement("p");
57-
assistantMessage.textContent = "Codriver: " + response;
57+
// Use innerHTML so markup from the AI shows up
58+
assistantMessage.innerHTML = "Codriver: " + response;
5859
assistantMessage.classList.add("assistant-message");
5960

6061
const assistantSpeaker = document.createElement("button");
@@ -64,6 +65,7 @@ function addAssistantMessage(response) {
6465
assistantContainer.appendChild(assistantMessage);
6566
assistantContainer.appendChild(assistantSpeaker);
6667
messageArea.appendChild(assistantContainer);
68+
messageArea.scrollTop = messageArea.scrollHeight;
6769
}
6870

6971
// External Fetches
@@ -81,7 +83,7 @@ async function fetchNews() {
8183
try {
8284
const response = await fetch(`https://api.nytimes.com/svc/topstories/v2/home.json?api-key=${NYT_API_KEY}`);
8385
const data = await response.json();
84-
return data.results.slice(0, 5).map(article => `• ${article.title}`).join("\n");
86+
return data.results.slice(0, 5).map(article => `• ${article.title}`).join("<br>");
8587
} catch {
8688
return "Sorry, I couldn't fetch the top news.";
8789
}
@@ -197,5 +199,4 @@ async function sendMessage() {
197199

198200
addAssistantMessage(response);
199201
userInput.value = "";
200-
messageArea.scrollTop = messageArea.scrollHeight;
201202
}

codriver/frontend/style.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,36 @@ body {
9393
margin: 5px 0;
9494
font-size: 16px;
9595
color: #000;
96+
line-height: 1.4;
97+
}
98+
99+
/* Styling for rendered HTML inside messages */
100+
.assistant-message b,
101+
.assistant-message strong {
102+
font-weight: bold;
103+
}
104+
105+
.assistant-message i,
106+
.assistant-message em {
107+
font-style: italic;
108+
}
109+
110+
.assistant-message u {
111+
text-decoration: underline;
112+
}
113+
114+
.assistant-message a {
115+
color: #0078d7;
116+
text-decoration: underline;
117+
cursor: pointer;
118+
}
119+
120+
.assistant-message ul,
121+
.assistant-message ol {
122+
padding-left: 20px;
123+
margin: 5px 0;
124+
}
125+
126+
.assistant-message li {
127+
margin-bottom: 3px;
96128
}

0 commit comments

Comments
 (0)