Skip to content

Commit

Permalink
Support Automatic Link Detection and Hyperlinking
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1513 committed Jul 15, 2024
1 parent 7bf4c04 commit 3971199
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
* cannot combine w/ `disallowedElements`.
* @property {string | null | undefined} [children]
* Markdown.
* @property {boolean | null | undefined} [autoLink]
* Automatically detect and add hyperlink to urls and emails.
* @property {string | null | undefined} [className]
* Wrap in a `div` with this class name.
* @property {Components | null | undefined} [components]
Expand Down Expand Up @@ -78,6 +80,7 @@
import {unreachable} from 'devlop'
import {toJsxRuntime} from 'hast-util-to-jsx-runtime'
import {urlAttributes} from 'html-url-attributes'
import {autoLinkMd} from 'react-markdown-autolink'
import {Fragment, jsx, jsxs} from 'react/jsx-runtime'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
Expand Down Expand Up @@ -163,7 +166,7 @@ export function Markdown(options) {
const file = new VFile()

if (typeof children === 'string') {
file.value = children
file.value = options.autoLink ? autoLinkMd(children) : children
} else {
unreachable(
'Unexpected value `' +
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"hast-util-to-jsx-runtime": "^2.0.0",
"html-url-attributes": "^3.0.0",
"mdast-util-to-hast": "^13.0.0",
"react-markdown-autolink": "^0.0.1",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.0.0",
"unified": "^11.0.0",
Expand Down

0 comments on commit 3971199

Please sign in to comment.