Plaint Text to HTML Link Converter-Anchorme. js
| Autor: | alexcorvi |
|---|---|
| Views Total: | 1,606 |
| Sitio oficial: | Ir a la web |
| Actualizado: | March 31, 2017 |
| Licencia: | MIT |
Vista prévia
Descripción
Anchorme. js es una biblioteca JavaScript simple pero robusta que encuentra URs, IPs, archivos y direcciones de correo electrónico en su texto sin formato y convertirlos en enlaces HTML clicables. Funciona con node. js y el explorador.
Instalación
# NPM $ npm install anchorme
Funcionamiento
// NPM
var anchorme = require("anchorme").default;
// ES6 / Typescript style imports
import anchorme from "anchorme"; O directamente incluir el anchorme. js de JavaScript en la Página Web.
<script src="anchorme.js"></script>
Uso básico:
anchorme(string,option)
Configuraciones predeterminadas.
anchorme(string,{
//addiontal attributes
attributes: [],
// converts IPs
ips: true,
// converts email addresses
emails: true,
// converts URLs
urls: true,
// converts files
files: true,
// truncate links
truncate: Infinity,
// default protocol
defaultProtocol: "http://",
// Although anchorme was authored to transform URLs in text strings to a click-able HTML anchor tags, passing `true` to `list` property in options will change the library's behavior and instead of returning a text with an HTML tags it will only return an array of valid URLs.
list: false
})





