Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/dotsunited/embed-parser
- Owner: dotsunited
- License: mit
- Created: 2017-05-16T07:49:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-17T07:09:36.000Z (over 7 years ago)
- Last Synced: 2024-04-26T13:21:38.814Z (7 months ago)
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.