GrahamCampbell / Laravel-Markdown

A CommonMark wrapper for Laravel
https://gjcampbell.co.uk/
MIT License
1.32k stars 139 forks source link

Not parsing to HTML #140

Closed noesnaterse closed 4 years ago

noesnaterse commented 4 years ago

I did al the setup instructions: composer require graham-campbell/markdown php artisan vendor:publish Then added 'Mail' => Illuminate\Support\Facades\Mail::class, to the aliases in config/app.php

That should be enough, so I do @markdown($page->body) in a blade.php file, and then it just outputs literally @markdown($page->body) When I change that to

@markdown
  {{ $page->body }}
@endmarkdown

it just print the @markdown the content (in markdown) end the endmarkdown.

I am using Laravel 7.0

GrahamCampbell commented 4 years ago

There is no Mail facade in this package, and you don't need to publish anything. All you need to do is install the package, and if you already rendered a view with this syntax, clear your view cache so it gets compiled again with the package.

GrahamCampbell commented 4 years ago

There is a test that shows this stuff working on Laravel 7: https://github.com/GrahamCampbell/Laravel-Markdown/blob/master/tests/Functional/stubs/qux.blade.php; https://github.com/GrahamCampbell/Laravel-Markdown/blob/master/tests/Functional/MarkdownViewTest.php#L67-L72.

noesnaterse commented 4 years ago

Whoops, I copied the wrong line. I meant I added 'Markdown' => GrahamCampbell\Markdown\Facades\Markdown::class, to the aliases in config/app.php as described in the readme: You can also optionally alias our facade.

The point is, that when I take the first snippet and paste it into my file.blade.php and try to render it using a browser. It just literally renders it out. So the output stays exactly the same.

GrahamCampbell commented 4 years ago

I am not able to replicate this, and we have tests to prove that it works, as I posted above. Are you able to produce an example failing test?

noesnaterse commented 4 years ago

hmmm, this always happens.

So I create a new Laravel app. Do according to the instructions:

Well, actually that is good, but in my real project it still goes wrong.

noesnaterse commented 4 years ago

It probably isn't something of this package...

GrahamCampbell commented 4 years ago

Do you have other packages messing about with views? Maybe those packages are doing something wrong which messes up view rendering.

noesnaterse commented 4 years ago

Not sure, but since I have two versions now (one working and one not) I can compare.

So, in my version not working, inside the MarkdownServiceProvider the boot function there is a statement if ($this->app->config->get('markdown.views')) This statement returns 1 in the version that is working but doesn't return anything in the version that is not working.

I thought it might have to do with config/markdown.php but with both projects this file is identical. I.e. no diff is being generated.

GrahamCampbell commented 4 years ago

Did you clear/regenerate your config cache?

noesnaterse commented 4 years ago

To get back on your question about other packages messing with views. I diffed the two package.json files and the only difference is guzzlehttp/guzzle version 6.3 and 6.5 So I don't think that is the answer.

cache:clear also clears the config cache right? To be certain I did a config:clear and a config:cache after the cache:clear but still it isn't working.

GrahamCampbell commented 4 years ago

Did you use the same version of composer? The current stable release of Laravel won't discover packages properly if you use the newest composer (any 2.x version). You'll need a composer 1.x version (until laravel releases a fix tomorrow).

noesnaterse commented 4 years ago

Yes, installed globally.

$ composer --version
Composer version 1.10.0 2020-03-10 14:08:05
$ which composer 
/usr/local/bin/composer
seongbae commented 3 years ago

If anyone has this issue, I was having same issue. I ran php artisan view:clear and it started working.