# material-ui-linkify

> Converts links in text to Material-UI Links using the Markdown Linkify library

Latest version **3.1.0** (published 2023-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install material-ui-linkify
pnpm add material-ui-linkify
yarn add material-ui-linkify
bun add material-ui-linkify
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2023-07-25 |
| First published | 2019-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 45.1 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | alexplumb |
| Keywords | material, react, linkify |

## Links

- npm: https://www.npmjs.com/package/material-ui-linkify
- Repository: https://github.com/alexplumb/material-ui-linkify
- Issues: https://github.com/alexplumb/material-ui-linkify/issues
- npm.io page: https://npm.io/package/material-ui-linkify

## Dependencies (3)

- [tlds](https://npm.io/package/tlds.md) ^1.240.0
- [linkify-it](https://npm.io/package/linkify-it.md) ^4.0.1
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.1.0 (latest) — 2023-07-25
- 3.0.0 — 2022-11-03
- 2.0.0 — 2021-09-23
- 1.1.3 — 2019-07-17
- 1.1.2 — 2019-05-03
- 1.1.1 — 2019-04-04
- 1.1.0 — 2019-04-04
- 1.0.1 — 2019-03-22
- 1.0.0 — 2019-03-06

## README

# material-ui-linkify
Converts links in text to Material-UI Links using the Markdown-it Linkify-it library
Uses https://github.com/markdown-it/linkify-it
Inspired by https://github.com/tasti/react-linkify/

## Installation

```shell-script
npm install material-ui-linkify --save
```

## Usage
### To use Material-UI-Linkify, add it ahead of any component you think might contain links
```
<MuiLinkify>
  <Typography variant="body1">
    See source code at https://github.com/alexplumb/material-ui-linkify
  </Typography>
</MuiLinkify>
```

### Properties
**schema** - A linkify-it schema for adding linkify processors. Example for adding Twitter:
```
{
  '@': {
    validate (text, pos, self) {
      const tail = text.slice(pos);

      if (!self.re.twitter) {
        self.re.twitter =  new RegExp(
          `^([a-zA-Z0-9_]){1,15}(?!_)(?=$|${self.re.src_ZPCc})`,
        );
      }
      if (self.re.twitter.test(tail)) {
        // Linkifier allows punctuation chars before prefix,
        // but we additionally disable `@` ("@@mention" is invalid)
        if (pos >= 2 && tail[pos - 2] === '@') {
          return false;
        }
        return tail.match(self.re.twitter)[0].length;
      }
      return 0;
    },
    normalize: (match) => {
      match.url = `https://twitter.com/${match.url.replace(/^@/, '')}`;
    },
  },
}
```

**options**: See https://github.com/markdown-it/linkify-it#new-linkifyitschemas-options for options

**LinkProps**: Properties that you want to pass along to the Link component. See https://material-ui.com/api/link/ for the full API

**hostnameOnly**: Forces certain schemas to only display the hostnames for matched links (boolean, default: false)

**hostnameSchemas**: When `hostnameOnly` is set to `true`, pass an array of schemas that determines which types of URLs to be truncated. (default: `https:, http:, ftp:, //`)

## Notes
This library requires the [URL interface](https://developer.mozilla.org/en-US/docs/Web/API/URL). If you need to support IE, make sure to install a polyfill.

## License
Uses the [MIT License](https://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/material-ui-linkify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
