shufo / prettier-plugin-blade

Format your blade template using Prettier
https://www.npmjs.com/package/@shufo/prettier-plugin-blade
MIT License
329 stars 8 forks source link

[Formatting Bug]: extra line in plain html with CRLF (windows, phpstorm) #244

Closed Yahav closed 8 months ago

Yahav commented 1 year ago

Version

1.13.1

Template before formatting

<div class="dashboard-card-header content">
                <div class="tw-flex tw-justify-between tw-items-center tw-flex-wrap sm:tw-flex-no-wrap">
                    <div class="tw-flex tw-items-center">
                        <div class="ui tiny selection dropdown">
                            <input type="hidden" id="selectedCommentsAction">
                            <i class="dropdown icon"></i>
                            <div class="default text">@lang('Bulk Actions')</div>
                            <div class="scrollhint menu">
                                @if(WebsiteModule::getSetting('comments', 'automatic_publish') === false)
                                    <div class="item" data-value="approve">@lang('Approve')</div>
                                @endif
                                <div class="item" data-value="delete">@lang('Delete')</div>
                            </div>
                        </div>
                        <div>
                            <button x-on:click="bulkAction()" class="ui tiny button tw-ml-1"  x-bind:class="{'disabled loading': actionState !== 'ready'}">@lang('Apply') <span x-text="'(' + selectedComments.length + ' Comments)'"></span></button>
                        </div>
                    </div>
                    @if(WebsiteModule::getSetting('comments', 'automatic_publish') === false)
                        <div class="tw-ml-0 sm:tw-ml-4 tw-mt-2 sm:tw-mt-0 tw-flex tw-flex-wrap tw-items-center tw-w-full sm:tw-w-auto tw-truncate">
                            <button x-on:click="markAllApproved()" id="commentsApproveAllButton" class="ui tiny labeled icon button" x-bind:class="{'disabled loading': actionState !== 'ready'}"><i class="check icon"></i> @lang('Approve All')</button>
                        </div>
                    @endif
                </div>
            </div>

Template after formatting

<div class="dashboard-card-header content">

        <div

          class="tw-flex tw-justify-between tw-items-center tw-flex-wrap sm:tw-flex-no-wrap">

          <div class="tw-flex tw-items-center">

            <div class="ui tiny selection dropdown">

              <input id="selectedCommentsAction" type="hidden">

              <i class="dropdown icon"></i>

              <div class="default text">@lang('Bulk Actions')</div>

              <div class="scrollhint menu">

                @if (WebsiteModule::getSetting('comments', 'automatic_publish') === false)

                  <div class="item" data-value="approve">@lang('Approve')</div>

                @endif

                <div class="item" data-value="delete">@lang('Delete')</div>

              </div>

            </div>

            <div>

              <button class="ui tiny button tw-ml-1" x-on:click="bulkAction()"

                x-bind:class="{ 'disabled loading': actionState !== 'ready' }">@lang('Apply')

                <span

                  x-text="'(' + selectedComments.length + ' Comments)'"></span></button>

            </div>

          </div>

          @if (WebsiteModule::getSetting('comments', 'automatic_publish') === false)

            <div

              class="tw-ml-0 sm:tw-ml-4 tw-mt-2 sm:tw-mt-0 tw-flex tw-flex-wrap tw-items-center tw-w-full sm:tw-w-auto tw-truncate">

              <button class="ui tiny labeled icon button"

                id="commentsApproveAllButton" x-on:click="markAllApproved()"

                x-bind:class="{ 'disabled loading': actionState !== 'ready' }"><i

                  class="check icon"></i> @lang('Approve All')</button>

            </div>

          @endif

        </div>

      </div>

Expected Behaviour

Shouldn't add those extra lines. If running blade-formatter directly it doesn't have this problem It might be related to: https://github.com/prettier/plugin-php/issues/665

Relevant log output

$blade-formatter resources/views/website/comments.blade.php

 <div class="dashboard-card-header content">
                <div class="sm:tw-flex-no-wrap tw-flex tw-flex-wrap tw-items-center tw-justify-between">
                    <div class="tw-flex tw-items-center">
                        <div class="ui tiny selection dropdown">
                            <input id="selectedCommentsAction" type="hidden">
                            <i class="dropdown icon"></i>
                            <div class="default text">@lang('Bulk Actions')</div>
                            <div class="scrollhint menu">
                                @if (WebsiteModule::getSetting('comments', 'automatic_publish') === false)
                                    <div class="item" data-value="approve">@lang('Approve')</div>
                                @endif
                                <div class="item" data-value="delete">@lang('Delete')</div>
                            </div>
                        </div>
                        <div>
                            <button class="ui tiny button tw-ml-1" x-on:click="bulkAction()"
                                x-bind:class="{ 'disabled loading': actionState !== 'ready' }">@lang('Apply') <span
                                    x-text="'(' + selectedComments.length + ' Comments)'"></span></button>
                        </div>
                    </div>
                    @if (WebsiteModule::getSetting('comments', 'automatic_publish') === false)
                        <div class="tw-truncate tw-ml-0 tw-mt-2 tw-flex tw-w-full tw-flex-wrap tw-items-center sm:tw-ml-4 sm:tw-mt-0 sm:tw-w-auto">
                            <button class="ui tiny labeled icon button" id="commentsApproveAllButton" x-on:click="markAllApproved()"
                                x-bind:class="{ 'disabled loading': actionState !== 'ready' }"><i class="check icon"></i> @lang('Approve All')</button>
                        </div>
                    @endif
                </div>
            </div>
github-actions[bot] commented 11 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days