# url-formatter

> A react-component that parses the urls of a given text and turns them to clickable hrefs

Latest version **0.1.3** (published 2021-07-14) · 0 weekly downloads

## Install

```sh
npm install url-formatter
pnpm add url-formatter
yarn add url-formatter
bun add url-formatter
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2021-07-14 |
| First published | 2021-07-14 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 8 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | john-atha |
| Maintainers | john-atha |
| Keywords | react, components, ui |

## Links

- npm: https://www.npmjs.com/package/url-formatter
- Repository: https://github.com/john-atha/url-formatter
- Homepage: https://github.com/john-atha/url-formatter#readme
- Issues: https://github.com/john-atha/url-formatter/issues
- npm.io page: https://npm.io/package/url-formatter

## Dependencies (8)

- [react](https://npm.io/package/react.md) ^17.0.2
- [react-dom](https://npm.io/package/react-dom.md) ^17.0.2
- [web-vitals](https://npm.io/package/web-vitals.md) ^1.1.2
- [react-scripts](https://npm.io/package/react-scripts.md) 4.0.3
- [@babel/polyfill](https://npm.io/package/@babel/polyfill.md) ^7.12.1
- [@testing-library/react](https://npm.io/package/@testing-library/react.md) ^11.2.7
- [@testing-library/jest-dom](https://npm.io/package/@testing-library/jest-dom.md) ^5.14.1
- [@testing-library/user-event](https://npm.io/package/@testing-library/user-event.md) ^12.8.3

## Alternatives

- [@progress/kendo-ooxml](https://npm.io/package/@progress/kendo-ooxml.md) — 152.1K weekly downloads
- [@progress/kendo-react-ripple](https://npm.io/package/@progress/kendo-react-ripple.md) — 8.0K weekly downloads
- [@progress/kendo-react-orgchart](https://npm.io/package/@progress/kendo-react-orgchart.md) — 4.3K weekly downloads
- [@praxisui/dynamic-fields](https://npm.io/package/@praxisui/dynamic-fields.md) — 2.4K weekly downloads
- [@mesalvo/react-ui](https://npm.io/package/@mesalvo/react-ui.md) — 1.7K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2021-07-14
- 0.1.2 — 2021-07-14
- 0.1.1 — 2021-07-14
- 0.1.0 — 2021-07-14

## README

# Url-Formatter

* This is a simple [ReactJs](https://reactjs.org) (with npx create-react-app) component to format the urls of a text

* It uses a simple javascript code snippet to split the text
* Then, a regural expression is used during render to filter the text parts, and with some HTML and CSS simple tricks, the urls are displayed as clickable hrefs
* Most importantly, <b>the initial text format (spaces, new lines, etc) remains the same</b>

## Quick demo 

[url-formatter](https://john-atha.github.io/url-formatter-demo)

## Github repository

[url-formatter](https://github.com/John-Atha/url-formatter)

## Installation

* Install using `npm i url-formatter`

## Quick start/Usage:

In a React app:
```javascript
    import { UrlFormatter } from 'url-formatter';
```
### Basic Usage
* Pass the text you want to format with the `text` prop
* Text should be a <b>string</b>
```javascript
    <UrlFormatter text={text} />
```
### Styling
#### Text container styling
* you can define the container styling giving the prop `style` which should be an object and follow the general rules of decalring styling in react (css)
* example:
```javascript
    <UrlFormatter text={text} style={{'border': '1px solid red'}}/>
```
#### Urls styling
* you can define the urls styling giving the prop `url` which should be an object (again following the general styling syntax)
* example:
```javascript
    <UrlFormatter text={text} url={{'color': 'red'}}/>
```
#### Other words styling
* you can define the simple words styling giving the prop `word` which should be an object (again following the general styling syntax)
* example:
```javascript
    <UrlFormatter text={text} word={{'color': 'red'}}/>
```
#### Space character length
* you can define the length of the space character giving the prop `space` as string
* the default value is 4px
* example:
```javascript
    <UrlFormatter text={text} space={'4px'}/>
```
#### In general, bear in mind that
* words are divided by whitespaces and then they are rendered as seperate divs
* as a result, they are going to inherit all their ancestors' CSS

## Contact me
* Developer: Giannis Athanasiou
* Github: [John-Atha](https://www.github.com/John-Atha)
* Email: giannisj3@gmail.com

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