Skip to content
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
eagostini committed Sep 2, 2019
2 parents f73fc23 + 15b2550 commit eaffedc
Show file tree
Hide file tree
Showing 12 changed files with 1,733 additions and 703 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.idea
/.phpunit.result.cache
/vendor
57 changes: 47 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@

[![Build Status](https://travis-ci.org/parsedown/laravel.svg?branch=master)](https://travis-ci.org/parsedown/laravel)

A [Laravel](https://github.com/laravel/laravel) wrapper of **Parsedown** to extend its features. If you want to know more about **Parsedown** alone check out our [base repository](https://github.com/erusev/parsedown).
This package is a [Laravel](https://github.com/laravel/laravel) wrapper around **Parsedown**. If you want to know more about **Parsedown** alone check out our [base repository](https://github.com/erusev/parsedown).

### Features

* Blade Directive
* Configuration File
* Helper Function

### Installation

**Parsedown for Laravel** is available as [a composer package](https://packagist.org/packages/parsedown/laravel). You can install it using the command below:
**Parsedown for Laravel** is available as [a **Composer** package](https://packagist.org/packages/parsedown/laravel). You can install it using the command below:

``` bash
composer require "parsedown/laravel"
composer require parsedown/laravel
```

### Configuration

If you're using **Laravel** +5.5 you don't need to follow the steps below. The [package auto-discovery](https://laravel-news.com/package-auto-discovery) feature has been implemented and will take care of loading the service provider for you.

But if that's not your case you just need to add the service provider to your `config/app.php`:
But if that's not your case you will need to add the service provider to your `config/app.php` file:
``` php
return [
// Other configurations above...
Expand All @@ -38,41 +39,77 @@ return [
];
```

This package uses the `Parsedown\Providers\ParsedownServiceProvider` service provider to create a singleton of **Parsedown**. That's stored it in a container called `parsedown`. It uses the following options to set the default behavior for that instance:

| Name | Description | Default |
|:-----------------|:-----------------------------------------------------------------------------------------------|:--------|
| `breaks_enabled` | Converts line breaks such as `\n` into `<br />` tags. | `false` |
| `inline` | Enables inline parsing for the `parsedown()` helper and the `@parsedown` directive by default. | `false` |
| `markup_escaped` | Escapes **HTML** in trusted input. Redundant if `safe_mode` is enabled. | `false` |
| `safe_mode` | Doesn't process untrusted user-input. | `true` |
| `urls_linked` | Automatically converts **URL**s into anchor tags. | `true` |

You can overwrite these values by publishing the `config/parsedown.php` file with the following command:

``` sh
php artisan vendor:publish --provider=Parsedown\Providers\ParsedownServiceProvider
```

### Usage

The snippets below show how you can easily use **Parsedown** in your `*.blade.php` files:

``` blade
@parsedown('Hello _Parsedown_!')
```

or (using a helper approach)
...or (using the helper approach)

``` blade
{{ parsedown('Hello _Parsedown_!') }}
```

Any of the codes above will generate:
Any of the code above will generate:

``` html
<p>Hello <em>Parsedown</em>!</p>
```

The helper can also be used with **PHP** throughout the project.
If you want to parse a value using the inline style you just need to set the second argument as `true`:

``` blade
@parsedown('Hello _Parsedown_!', true)
```

...or (using the helper approach)

``` blade
{{ parsedown('Hello _Parsedown_!', true) }}
```

Any of the code above will generate:

``` html
Hello <em>Parsedown</em>!
```

The helper is globally available and can also be used with **PHP** code throughout your project.

## Lumen Support

As **Laravel** and **Lumen** share pretty much the same core the instructions below should be enough to set this package in yout **Lumen** project.
**Laravel** and **Lumen** pretty much share the same core code. The instructions below should be enough to set this package for your **Lumen** project.

### Enable Facades in Your Project

In your `bootstrap/app.php` ensure you have the following:
Ensure you have the following in your `bootstrap/app.php` file:

```php
$app->withFacades();
```

### Service Provider Registering

As **Lumen** does not support package auto-discovery you got to do it manually adding the code below in your `bootstrap/app.php`:
As **Lumen** does not support package auto-discovery you got to do it manually adding the code below in your `bootstrap/app.php` file:

```php
$app->register(Parsedown\Providers\ParsedownServiceProvider::class);
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parsedown/laravel",
"description": "Official Laravel Wrapper of Parsedown.",
"description": "Official Parsedown's Laravel Wrapper.",
"keywords": [
"parsedown",
"laravel"
Expand All @@ -18,13 +18,13 @@
}
],
"require": {
"php": ">=5.6",
"erusev/parsedown": "~1.6"
"php": ">=7.1.3",
"erusev/parsedown": "^1.7"
},
"require-dev": {
"orchestra/testbench": "^3.4",
"php": ">=7.1",
"phpunit/phpunit": "^6.3"
"php": ">=7.2",
"orchestra/testbench": "^3.8",
"phpunit/phpunit": "^8.3"
},
"autoload": {
"files": [
Expand Down
Loading

0 comments on commit eaffedc

Please sign in to comment.