❄️ The winter sale is here. 25% off for a limited time. Join us →

Livewire
Laravel markdown package code highlighting is not working
4
362
Solved

Polash

Started this discussion 2 months ago

Hi, I'm using the Inertia and Laravel markdown package on my project. Locally it's working perfectly. But the problem is when I'm up on the server Markdown's style is breaking.

this screenshot for my local server: https://yourimageshare.com/ib/syhLlywmwI

and this screenshot for my online VPS server https://yourimageshare.com/ib/mB472F59T0

the code highlighting is broken. Can anyone tell me how to fix it?

whoami (Daryl)

Replied 2 months ago

Which package do you use? And also, share your browser's console, maybe there's something there.

Polash

Replied 2 months ago

I'm using Laravel Markdown package. The browser console is clear, no problems are showing there. I think I found the problem but I don't know how to solve it. I created a route, which when I called converts the text to markdown style. This API is working locally but not returning Markdown style on the VPS server. Here is my code:

class MarkdownController extends Controller
{
    public function __invoke(Request $request)
    {
        return response()->json([
           'html' => app(MarkdownRenderer::class)->toHtml($request->body ?? '')
        ]);
    }
}

Locally response:

{ "html": "<pre class="shiki" style="background-color: #FFFFFF"><span class="line"><span style="color: #000000"> </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">function</span><span style="color: #000000"> </span><span style="color: #795E26">variations</span><span style="color: #000000">()</span></span>\n<span class="line"><span style="color: #000000"> {</span></span>\n<span class="line"><span style="color: #000000"> </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #0000FF">$this</span><span style="color: #000000">-></span><span style="color: #795E26">belongsToMany</span><span style="color: #000000">(</span><span style="color: #267F99">Variation</span><span style="color: #000000">::</span><span style="color: #0000FF">class</span><span style="color: #000000">)</span></span>\n<span class="line"><span style="color: #000000"> -></span><span style="color: #795E26">withPivot</span><span style="color: #000000">(</span><span style="color: #A31515">'quantity'</span><span style="color: #000000">);</span></span>\n<span class="line"><span style="color: #000000"> }</span></span>\n<span class="line"></span></code></pre>\n" }


VPS server response:
{ "html": "public static function booted()\n {\n static::creating(function ($model) {\n $model->uuid = Str::uuid();\n });\n }\n\n \n</code>\n" }


shiki is not working when vps server converts to markdown style.

Best answer

Polash

Replied 2 months ago

Problem solved, I had a problem with my node version.

whoami (Daryl)

Replied 1 month ago

Great!