-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into release/v0.2
merge in latest dev .
- Loading branch information
Showing
6 changed files
with
98 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
import React, { ReactNode } from 'react'; | ||
import ReactMarkdown from 'react-markdown'; | ||
|
||
//====================================== | ||
export const Markdown = ({ children }: { children: string }) => { | ||
// regex to match URLs in text that arent already formatted as links in markdown | ||
const urlRegex = /(?<!\]\()https?:\/\/[^\s]+(?!\))/g; | ||
|
||
// add markdown syntax to format links in text if they aren't already marked | ||
const processedText = children.replace(urlRegex, (url) => `[${url}](${url})`); | ||
|
||
return ( | ||
<ReactMarkdown | ||
components={{ | ||
ul: (props) => <ul className="list-disc" {...props} />, | ||
a: (props) => <a className="text-blue-400 underline" {...props} />, | ||
a: (props) => ( | ||
<a className="testerino text-blue-400 underline" target="_blank" {...props} /> | ||
), | ||
code: (props) => <code className="text-orange-300" {...props} />, | ||
}} | ||
> | ||
{children} | ||
{processedText} | ||
</ReactMarkdown> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters