Skip to content

Commit

Permalink
fix: change to use marked
Browse files Browse the repository at this point in the history
  • Loading branch information
shibbas committed Nov 7, 2023
1 parent b1baf35 commit 9d1fdea
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 54 deletions.
51 changes: 9 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/chat-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"dompurify": "^3.0.6",
"lit": "^2.8.0",
"markdown-it": "^13.0.2"
"marked": "^9.1.5"
},
"devDependencies": {
"@types/dompurify": "^3.0.3",
Expand Down
9 changes: 2 additions & 7 deletions packages/chat-component/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { parseStreamedMessages } from './core/parser/index.js';
import { mainStyle } from './style.js';
import { getTimestamp, processText } from './utils/index.js';
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
import markdownIt from 'markdown-it';

// TODO: allow host applications to customize these icons

Expand All @@ -20,6 +19,7 @@ import iconCopyToClipboard from '../public/svg/copy-icon.svg?raw';
import iconSend from '../public/svg/send-icon.svg?raw';
import iconClose from '../public/svg/close-icon.svg?raw';
import iconQuestion from '../public/svg/question-icon.svg?raw';
import { marked } from 'marked';

/**
* A chat component that allows the user to ask questions and get answers from an API.
Expand All @@ -32,11 +32,6 @@ import iconQuestion from '../public/svg/question-icon.svg?raw';
* @fires chat-component#defaultQuestionClicked - Fired when the user clicks on a default question
* */

const md = markdownIt({
html: true,
linkify: true,
});

@customElement('chat-component')
export class ChatComponent extends LitElement {
//--
Expand Down Expand Up @@ -232,7 +227,7 @@ export class ChatComponent extends LitElement {
const previewer = this.shadowRoot?.querySelector('#citation-previewer');
if (previewer) {
const markdownContent = await response.text();
previewer.innerHTML = DOMPurify.sanitize(md.render(markdownContent));
previewer.innerHTML = DOMPurify.sanitize(marked.parse(markdownContent));
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions packages/chat-component/src/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,6 @@ export const mainStyle = css`
}
.items__listItem--citation.active {
background-color: var(--accent-high);
.items__link {
color: var(--white);
}
}
.items__listItem--citation:not(first-child) {
margin-left: 5px;
Expand All @@ -417,6 +413,9 @@ export const mainStyle = css`
text-decoration: none;
color: var(--text-color);
}
.items__listItem--citation.active .items__link {
color: var(--white);
}
.steps .items__listItem--step {
padding: 5px 0;
border-bottom: 1px solid var(--light-gray);
Expand Down

0 comments on commit 9d1fdea

Please sign in to comment.