1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[laravel11]デフォルトのmarkdown(html)メール使おうとしたら表記が崩れる

Last updated at Posted at 2024-10-14

何が起きた?

公式リファレンスのmarkdownの部分に従ってメールを作成したところ下記図のようになりました。

image.png

症状としては、一部のタグが文字列として認識されてしまっている状況です。

該当箇所は以下の通りなのですが皆さんは何が悪いか分かりますか?(筆者にはわかりませんでした。。。)

誤っているbladeファイル
<x-mail::message>
(〜前略〜)
    # 無料トライアルの登録が完了しました!

    <x-mail::button :url="url('/login')">
        ログイン画面を開く
    </x-mail::button>

    ※既にログイン済みの場合はトップページが開かれます。

    ※このメールに対して覚えがない場合は、そのままお読み捨てください。
(〜後略〜)
</x-mail::message>

結論

htmlを使う記述にインデントが入っているからでした。

正しいbladeファイル
<x-mail::message>
(〜前略〜)
    # 無料トライアルの登録が完了しました!

{{-- インデントを削除した --}}
<x-mail::button :url="url('/login')">
    ログイン画面を開く
</x-mail::button>

    ※既にログイン済みの場合はトップページが開かれます。

    ※このメールに対して覚えがない場合は、そのままお読み捨てください。
(〜後略〜)
</x-mail::message>

おそらくmarkdownを実装するときの裏仕様なのだと思うのですが、公式を調べた限りではそんなこと書いておらず、筆者は2時間ほど虚無を彷徨いました。

なのでみなさんが同じ部分でつまづかないようになればと思いこの記事を書きました。

解決につながった記事

ちなみに筆者はこちらの記事のおかげで解決できました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?