Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dotsunited/embed-parser

Simple utility to parse URLs in HTML or text content which are placed on its own line to turn them into embeds.
https://github.com/dotsunited/embed-parser

Last synced: about 20 hours ago
JSON representation

Simple utility to parse URLs in HTML or text content which are placed on its own line to turn them into embeds.

Awesome Lists containing this project

README

        

Embed Parser
============

Simple utility to parse URLs in HTML or text content which are placed on its own
line to turn them into embeds.

Installation
------------

Install the latest version with [Composer](https://getcomposer.org).

```bash
composer require dotsunited/embed-parser
```

Check the [Packagist page](https://packagist.org/packages/dotsunited/embed-parser)
for all available versions.

Usage
-----

There is single `parse` function provided which parses the given content and
invokes a handler callback for each URL found.

```php
$transformedContent = DotsUnited\EmbedParser\parse($content, function ($url) {
$embedHtml = tranformUrlToEmbedHtml($url);

return $embedHtml;
});
```

The URL must be on its own line or surrounded only by `

` tags with no other
text content to be parsed.

### Text

```text
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua.

https://youtube.com/watch?v=QcIy9NiNbmo

At vero eos et accusam et justo duo dolores et ea rebum.
```

### HTML

```html


Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua.


https://youtube.com/watch?v=QcIy9NiNbmo


At vero eos et accusam et justo duo dolores et ea rebum.


```

License
-------

Copyright (c) 2017 Dots United GmbH.
Released under the [MIT](LICENSE) license.