https://github.com/opensly/anchored
Transform plain URLs into clickable links for a seamless user experience.
https://github.com/opensly/anchored
Last synced: about 1 year ago
JSON representation
Transform plain URLs into clickable links for a seamless user experience.
- Host: GitHub
- URL: https://github.com/opensly/anchored
- Owner: opensly
- License: mit
- Created: 2024-11-08T04:16:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-09T02:44:01.000Z (over 1 year ago)
- Last Synced: 2025-02-06T17:11:39.551Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Anchored.js
Anchored.js is a lightweight JavaScript library for transforming plain URLs in text into clickable links. The function uses a regex-based approach to identify URLs, creating a DocumentFragment containing both links and plain text, suitable for DOM manipulation.
## Features
- Transforms plain URLs (e.g., https://example.com) into clickable links.
- Supports common URL formats (http://, https://, www, etc.).
- Can be used in various environments: browser, ES6 modules, and Node.js.
## Usage Guide
### In a browser (Global Script)
Include the `anchored.js` script in an HTML file:
```
const text = "Check this out: https://example.com and also http://test.com.";
const result = anchored(text);
document.body.appendChild(result);
```
### In a Module (ES6/JavaScript Module)
```
import anchored from './path/to/anchored.js';
const text = "Visit https://example.com and http://test.com!";
const result = anchored(text);
document.body.appendChild(result);
```
### In a Node.js (CommonJS Module)
```
const anchored = require('./path/to/anchored.js');
const text = "Find more at https://example.com!";
const result = anchored(text);
document.body.appendChild(result);
```
### In a Webpack or Babel Environment (ES6 Module)
After installing the module using Webpack/Babel:
```
import anchored from './path/to/anchored.js';
const text = "Here is https://example.com, check it out!";
const result = anchored(text);
document.getElementById("content").appendChild(result);
```
## Support
Your support inspires & encourage us more. If you are interested to make a donation to us, please click the below PayPal button.
[](https://www.paypal.me/LakshmikanthV)
## License
This project is licensed under the MIT License.