-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 In HTML Attributes #1620
Comments
@RiFi2k |
@bitwiseman Haha, I wasn't planning on parsing the HTML or anything nutty with a regex, just changing double quotes to single or the reverse. But I will most certainly defer to your plan, I'm not in a rush to patch anything none of it is show stopping. If you have any related tasks you wanted to lay off all you got to do is ask I'm more than happy to help, your always right on everything and I appreciate you! |
@RiFi2k Take a look at 1.9.0-beta2 now up on https://beautifier.io . |
@bitwiseman You notice that the force wrap doesn't work anymore too? |
Apart from that it was working out great, and it would wrap if it hit the line length, just wouldn't auto wrap after the first. You put in some serious work on this. |
@RiFi2k |
@bitwiseman So it's late haha, I wrote auto instead of force in the options. Working as expected so far. |
You are truely the man, can't believe you got # 9 fully working in my examples. |
Description
Formatting the HTML code in PHP files as it pertains to having inline PHP set in or as HTML attributes. I'll try to include pretty much every usecase or variation I have seen so far also whatever relevant examples that have been reported to me via my VSCode extension which formats the HTML code in PHP files.
I think this can pretty much be broken down into 3 high level sections:
1. Just the tag name
Input
Expected Output
Actual Output
2. Tag name and attributes
Input
Expected Output
Actual Output
3. These could also be echoed so you might see long or short syntax
Input
Expected Output
Actual Output
4. Also with or without spaces on the short syntax
Input
Expected Output
Actual Output
5. Random mix no space between attribute and PHP tag
Input
Expected Output
Actual Output
6. Random mix w/ space
Input
Expected Output
Actual Output
7. Short echo - This one is kind of cheap because most editors would throw some error or warning or at least mess up the syntax coloring on the document with this one.
Input
Expected Output
Actual Output
7A. Short echo - Swapping settings.
Input
Expected Output
Actual Output
8. Traditional echo
Input
Expected Output
Actual Output
9. PHP ternary operator w/ super annoying syntax (people do write things like this if you troll WP plugins / themes, I stole this code more or less from one)
Input
Expected Output
Actual Output
Environments
https://beautifier.io & JS API
Settings
Relevant Setting:
On examples 7, 7a, 8 the ones that get messed up because there are double-quotes inside the PHP tags and when beautified odviously the first instance of the double-quotes inside the attribute gets mistaken for another attribute thus the space is added in "auto" mode. My quick fix in my extension on that, because I'm guessing it may fall outside the scope of what your willing to fix. Is going to be something like this.
phpInAttr.js
extension.js
Basically locate any html attribute setup like
attribute="$code"
where$code
contains any"
then replace them all with'
, don't know though that could potentionally be dangerous and break some PHP code in some cases.The text was updated successfully, but these errors were encountered: