Add linkify extension
This commit is contained in:
parent
259727aa0f
commit
a0dee01512
3 changed files with 57 additions and 3 deletions
12
app/Note.php
12
app/Note.php
|
@ -7,11 +7,16 @@ use Twitter;
|
|||
use Normalizer;
|
||||
use GuzzleHttp\Client;
|
||||
use Laravel\Scout\Searchable;
|
||||
use League\CommonMark\Converter;
|
||||
use League\CommonMark\DocParser;
|
||||
use Jonnybarnes\IndieWeb\Numbers;
|
||||
use League\CommonMark\Environment;
|
||||
use League\CommonMark\HtmlRenderer;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Jonnybarnes\EmojiA11y\EmojiModifier;
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Jonnybarnes\CommonmarkLinkify\LinkifyExtension;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
||||
class Note extends Model
|
||||
|
@ -128,9 +133,12 @@ class Note extends Model
|
|||
*/
|
||||
public function getNoteAttribute($value)
|
||||
{
|
||||
$markdown = new CommonMarkConverter();
|
||||
$environment = Environment::createCommonMarkEnvironment();
|
||||
$environment->addExtension(new LinkifyExtension());
|
||||
$converter = new Converter(new DocParser($environment), new HtmlRenderer($environment));
|
||||
$emoji = new EmojiModifier();
|
||||
$html = $markdown->convertToHtml($value);
|
||||
|
||||
$html = $converter->convertToHtml($value);
|
||||
$hcards = $this->makeHCards($html);
|
||||
$hashtags = $this->autoLinkHashtag($hcards);
|
||||
$modified = $emoji->makeEmojiAccessible($hashtags);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
"ezyang/htmlpurifier": "~4.6",
|
||||
"guzzlehttp/guzzle": "~6.0",
|
||||
"indieauth/client": "~0.1",
|
||||
"jonnybarnes/commonmark-linkify": "^0.1.0",
|
||||
"jonnybarnes/emoji-a11y": "^0.3",
|
||||
"jonnybarnes/indieweb": "dev-master",
|
||||
"jonnybarnes/webmentions-parser": "0.4.*",
|
||||
|
|
47
composer.lock
generated
47
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "0f8de1d2b229308f3862ff61f5468fcf",
|
||||
"content-hash": "4d74fa17d49cf82d75452686d13b3610",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aws/aws-sdk-php",
|
||||
|
@ -1453,6 +1453,51 @@
|
|||
],
|
||||
"time": "2015-09-27T15:35:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jonnybarnes/commonmark-linkify",
|
||||
"version": "v0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jonnybarnes/commonmark-linkify.git",
|
||||
"reference": "e2db28ede8d82fc040131e9137c167805f16a1a9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/jonnybarnes/commonmark-linkify/zipball/e2db28ede8d82fc040131e9137c167805f16a1a9",
|
||||
"reference": "e2db28ede8d82fc040131e9137c167805f16a1a9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"league/commonmark": "^0.15.4",
|
||||
"php": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~6.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Jonnybarnes\\CommonmarkLinkify\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"CC0-1.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jonny Barnes",
|
||||
"email": "jonny@jonnybarnes.uk"
|
||||
}
|
||||
],
|
||||
"description": "Turn plaintext urls into clickable links",
|
||||
"homepage": "https://github.com/jonnybarnes/commonmark-linkify",
|
||||
"keywords": [
|
||||
"commonmark",
|
||||
"markdown"
|
||||
],
|
||||
"time": "2017-07-07T16:05:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jonnybarnes/emoji-a11y",
|
||||
"version": "v0.3",
|
||||
|
|
Loading…
Add table
Reference in a new issue