Skip to content

Commit

Permalink
feat: support latex format
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Jan 17, 2024
1 parent deff1f5 commit 5b61da7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions web/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Providers from '@/containers/Providers'

import '@/styles/main.scss'

import 'katex/dist/katex.min.css'

export const metadata: Metadata = {
title: 'Jan',
description:
Expand Down
2 changes: 2 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
"framer-motion": "^10.16.4",
"highlight.js": "^11.9.0",
"jotai": "^2.4.0",
"katex": "^0.16.9",
"lodash": "^4.17.21",
"lucide-react": "^0.291.0",
"marked": "^9.1.2",
"marked-highlight": "^2.0.6",
"marked-katex-extension": "^4.0.5",
"next": "14.0.1",
"next-themes": "^0.2.1",
"postcss": "8.4.31",
Expand Down
4 changes: 3 additions & 1 deletion web/screens/Chat/SimpleTextMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { ChatCompletionRole, MessageStatus, ThreadMessage } from '@janhq/core'
import hljs from 'highlight.js'

import { useAtomValue } from 'jotai'
import { Marked, Renderer } from 'marked'
import { Marked, Renderer, use } from 'marked'

import { markedHighlight } from 'marked-highlight'
import markedKatex from 'marked-katex-extension'

import { twMerge } from 'tailwind-merge'

Expand All @@ -31,6 +32,7 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
const clipboard = useClipboard({ timeout: 1000 })

const marked: Marked = new Marked(
markedKatex({ displayMode: true, macros: true, throwOnError: false }),
markedHighlight({
langPrefix: 'hljs',
highlight(code, lang) {
Expand Down

0 comments on commit 5b61da7

Please sign in to comment.