New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<?php ignoring ?> #532
Comments
|
For example we can have: <?php
$hellooo = 'world';
$world = 'hello';
foreach ($array as $key => $value) {
do->SomethingWith($value);
}
?> jsB converts it into: <?php $hellooo='world' ; $world='hello' ; foreach ($array as $key=>$value) { do->SomethingWith($value); } ?> As you can see, jsB destroys the original text. It parses the whole block as a single tag with attributes. if (content[1] && content[1] === '!' || content[1] && content[1] === '?') { Changed line 430: } else if (tag_check.charAt(0) === '!' || tag_check.charAt(0) === '?') { And from line 500 I added: } else if (comment.indexOf('<?') === 0) { // <!-- php ...
delimiter = '?>';
matched = true;
} I know, that it is not the best solution for this issue, but it does exactly what I need. |
That an interesting description of some changes you've made to some version of the files. It seems like the harder thing you want done is not shown in your example: "... to indent the contents inside ... (for ... endfor, foreach ... endforeach)." In any case, I'm pretty sure what you're asking for we be better described as "php-beautify" and is thus out of scope for this any of the beautifiers we have. But as I said, you've described some changes. Feel free to commit those changes and submit a pull request. |
Sorry, it was nearly 4 am, so I lost some things from my mind. What I want from you is to use the idea of thinking about php tags as comment ones and make a better feature, when php content is ignored. For your future releases I'd like your script to detect '', look inside it for 'if', 'for' and 'foreach' and indent everything until it detects the next with endif, endfor, endforeach inside. I do not know, if I can make it by myself. |
I'm going to close this in favor of #490 and a new issue to track creating a php beautifier. |
I use your script to prettify my php scripts.
The problem is that your script thinks that tag is a single-liner, but its not.
So I've done some changes to your script to make it recognize as a comment, and it won't break my php scripts.
Can you please add such feature?
The text was updated successfully, but these errors were encountered: