Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mlazuardy's avatar

Avoid HTML tag/blade inside source code editor on markdown to be view

i dont know what this problem call it, but when i want to use triple backtick and put my source code of blade, save it and display it, All of my html body dissapear, i dont know why but can somebody help me?

0 likes
13 replies
mlazuardy's avatar

i use the markdown for source code like this

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Register</div>

                <div class="panel-body">
                    <form class="form-horizontal" method="POST" action="{{ route('register') }}">
                        {{ csrf_field() }}

                        <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
                            <label for="name" class="col-md-4 control-label">Name</label>

                            <div class="col-md-6">
                                <input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus>

                                @if ($errors->has('name'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('name') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                            <label for="email" class="col-md-4 control-label">E-Mail Address</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>

                                @if ($errors->has('email'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                            <label for="password" class="col-md-4 control-label">Password</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control" name="password" required>

                                @if ($errors->has('password'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('password') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>

                            <div class="col-md-6">
                                <input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <button type="submit" class="btn btn-primary">
                                    Register
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

but the source code is render to be an html and then. they show the All inside the triple backtick, not the code, please help me

RiccardoGaleazzi's avatar

Your view file must be named: file.blade.php

Without the blade key, it doesn't work.

mlazuardy's avatar

what do you mean? i dindnt have any view name except blade. only blade.php sir

but the triple backtick its going to be paragraph, not pre code if i use php source code it work normal, but if i use that blade syntax and html. they renderit into html tag . and dissappear @RiccardoGaleazzi

RiccardoGaleazzi's avatar

What's your file name in /resources/views/ ? How do you call it from controller? The problem is not the blade syntax but how you call it.

mlazuardy's avatar

store method


    public function store(Request $request, Tag $tag)
    {
        $this->validate(request(), [
        'title'    =>'required|max:100',
        'body'    =>'required',
        'category_id'  =>'required',

      ]);

        $post = new Post;
        $post->title = title_case($request->title);
        $post->body  = $request->body;
        $post->slug  = str_slug($request->title);
        $post->excerpt = str_limit($request->body,100);
        $post->category_id = $request->category_id;
        $post->meta_description = str_limit($request->body,200);
        $post->meta_keywords = $request->title;
        $post->seo_title    = $request->title;
        //save Image
        if ($request->hasFile('image')) {
            $request->file('image')->store('public/posts/'.$request->user()->username);
            $post->image = $request->file('image')->hashName('posts/'.$request->user()->username.'/');
        }

        $tags_id = [];
        if ($request->tags) {
            $tags = explode(',', $request->tags);
            foreach ($tags as $tag) {
                $tag_ref = Tag::firstOrCreate(['name' => str_slug($tag, '-')]);
                $tags_id[] = $tag_ref->id;
            }
        }
        $post->save();
        Alert::message('Selanjutnya akan di Review Oleh Admin', 'Artikel Sukses Dibuat')->persistent('close');
        $post->tags()->sync($tags_id);
        return redirect('/profile/post')->with('success', 'Post Berhasil dibuat');
    }

show method

  public function show($slug)
    {
        $blog_key = 'blog_'.$slug;
        if (!Session::has($blog_key)) {
            Post::where('slug', $slug)->increment('view_count');
            Session::put($blog_key, 1);
        }
        $bestPosts = Post::where('featured', 1)->paginate(3);
       
       $post = Post::where('slug', $slug)
                ->where('status', 'PUBLISHED')
                  ->firstOrFail();
            $tags = $post->tags->map(function ($tag) {
            return $tag->name;
        });
        $commentPaginator = $post->comments()->paginate(10);
        if (!$post) {
            abort(404);
        }
        return view('post.show')->with(['post'=>$post,'commentPaginator'=>$commentPaginator,'bestPosts'=>$bestPosts,'tags'=>$tags]);
    }

any wrong with it ? @RiccardoGaleazzi

RiccardoGaleazzi's avatar

It seems ok! So you have a folder post/ with the show file. What is its full name? show.php or show.blade.php ?

If the problem is not here it's difficult to replicate this situation. Let me know @mlazuardy

Snapey's avatar

I don't understand the issue.

You are trying to build an input component that can handle html source?

Where is the input field?

What are you using to process markdown?

Why have you shown registration code?

mlazuardy's avatar

okay i hope you'll understand. i use SimpleMDE (markdown editor) to save my Body Column inside posts table, where Body is input in textarea like this

   <div class="field ">
                  <textarea name="body" id="text-editor" cols="30" rows="10"></textarea>
                 </div>

after that, i call the id of my textarea in the bottom of my view.blade

<script >
  var simplemde = new SimpleMDE({ element: document.getElementById("text-editor"), spellChecker: false });
  $("input, text-editor, select").change(function() {
    contentChanged(true);
});
  </script>

if i create the post, all working perfectly, and i use laravel/parsedown to parsing the markdown inside text-area and turn the markdown style into html tag. and collect the body column inside the posts table like this

{!! parsedown($post->body) !! } 

They all work Good, But when i input the source code inside the triple backtick ( i insert default of laravel register.blade.php ) between the backtick so I expected they will show as source code like we use on Laracast ( triple backtick->code>triple backtick) But the code is generate into html tag, But didnt show in my post/show, they all dissapear. they didnt generate my code inside triple backtick into pre>code.

mlazuardy's avatar

Im sorry for bad explanation and bad english, but i found the trouble, its say vue error compiling assets, but i dont know what's that mean? @RiccardoGaleazzi do you have any idea?

Please or to participate in this conversation.