Hirse / brackets-beautify

Brackets Extension to beautify JavaScript, HTML, and CSS files.
MIT License
34 stars 3 forks source link

PHP HEREDOC Syntax issue #25

Open sethleedy opened 7 years ago

sethleedy commented 7 years ago

When used on a PHP file, the reformatting of the code will goof up the HEREDOC syntax. HEREDOC required the end block word to be aligned on the left side of the document. Beautify will not keep it there.

Test code:

<?php
function display_Calculator() {

    $myFile = htmlspecialchars($_SERVER['PHP_SELF']);

    $htmlCode=<<<HCODE <div class="container">
    <div class="col-sm-6 col-sm-offset-3 col-xs-12">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">PHP Tip Calculator Example</h3>
            </div>
            <div class="panel-body">

                <form action="<?php echo $myFile; ?>" method="POST" class="form-horizontal">
    <div class="form-group form-group-lg">
        <label for="amountBill" class="control-label col-xs-2 col-sm-3">Bill Amount:</label>
        <div class="col-sm-9">
            <input name="amountBill" id="amountBill" class="form-control" type="text" placeholder="$0.00">
        </div>
    </div>
    <div class="form-group form-group-lg">
        <label for="amountTip" class="control-label col-xs-2 col-sm-3">Tip Percent:</label>
        <div class="col-sm-9">
            <input name="amountTip" id="amountTip" class="form-control" type="text" placeholder='0%'>
        </div>
    </div>
    <div class="form-group form-group-lg ">
        <div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-push-2">
            <button name="btnCalculate" type="submit" class="bn btn-sm btn-primary btn-block">Calculate</button>
        </div>
    </div>

    </form>

    </div>
    </div>
    </div>
    </div>

HCODE;

    echo $htmlCode;
}

?>

Try the above code and "Beautify" it.

Hirse commented 7 years ago

PHP formatting is done by using the HTML mode of the js-beautify library. Please open an issue there and link it here.