Skip to content

Commit

Permalink
fix: add markdown support for extension description (#2691)
Browse files Browse the repository at this point in the history
Signed-off-by: James <[email protected]>
Co-authored-by: James <[email protected]>
  • Loading branch information
namchuai and James authored Apr 11, 2024
1 parent 3deaa8f commit 7d67087
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion extensions/inference-nitro-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@janhq/inference-nitro-extension",
"productName": "Nitro Inference Engine",
"version": "1.0.0",
"description": "This extension embeds Nitro, a lightweight (3mb) inference engine written in C++. See https://nitro.jan.ai.\nUse this setting if you encounter errors related to **CUDA toolkit** during application execution.",
"description": "This extension embeds Nitro, a lightweight (3mb) inference engine written in C++. See https://nitro.jan.ai.\nAdditional dependencies could be installed to run without Cuda Toolkit installation.",
"main": "dist/index.js",
"node": "dist/node/index.cjs.js",
"author": "Jan <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion web/screens/Settings/CoreExtensions/ExtensionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const ExtensionItem: React.FC<Props> = ({ item }) => {
const description = marked.parse(item.description ?? '', { async: false })

return (
<div className="mx-6 flex w-full items-start justify-between border-b border-border py-4 py-6 first:pt-4 last:border-none">
<div className="mx-6 flex w-full items-start justify-between border-b border-border py-6 first:pt-4 last:border-none">
<div className="flex-1 flex-shrink-0 space-y-1.5">
<div className="flex items-center gap-x-2">
<h6 className="text-base font-bold">Additional Dependencies</h6>
Expand Down
25 changes: 21 additions & 4 deletions web/screens/Settings/CoreExtensions/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import React, { useState, useEffect, useRef } from 'react'

import { Button, ScrollArea } from '@janhq/uikit'
import { Marked, Renderer } from 'marked'

import Loader from '@/containers/Loader'

Expand Down Expand Up @@ -88,9 +88,16 @@ const ExtensionCatalog = () => {
{item.version}
</h6>
</div>
<p className="whitespace-pre-wrap leading-relaxed ">
{item.description}
</p>
{
<div
dangerouslySetInnerHTML={{
// eslint-disable-next-line @typescript-eslint/naming-convention
__html: marked.parse(item.description ?? '', {
async: false,
}),
}}
/>
}
</div>
</div>
)
Expand Down Expand Up @@ -130,4 +137,14 @@ const ExtensionCatalog = () => {
)
}

const marked: Marked = new Marked({
renderer: {
link: (href, title, text) => {
return Renderer.prototype.link
?.apply(this, [href, title, text])
.replace('<a', "<a class='text-blue-500' target='_blank'")
},
},
})

export default ExtensionCatalog

0 comments on commit 7d67087

Please sign in to comment.