Skip to content
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

Duplicating HTML Code Nested In PHP #1483

Closed
RiFi2k opened this issue Aug 12, 2018 · 4 comments
Closed

Duplicating HTML Code Nested In PHP #1483

RiFi2k opened this issue Aug 12, 2018 · 4 comments

Comments

@RiFi2k
Copy link

RiFi2k commented Aug 12, 2018

So I use this library in a vscode extension which formats HTML code inside PHP files. I found this just now when going to publish a new version.
This is going from 1.8.0-rc4 > 1.8.0-rc5 so it has to be something in there because I tested the same situation in both versions with no other changes.

Node.js version

Input

<?php
/**
 * Comment
 */

?>
<div class="">

</div>

Output

<?php
/**
 * Comment
 */

?>
<div
<?php
/**
 * Comment
 */

?>
<div
<?php
/**
 * Comment
 */

?>
<div
<?php
/**
 * Comment
 */

?>
<div
<?php
/**
 * Comment
 */

?>
<div

</div>

If you lose the class attribute completely off the div tag then it's completely fine, but adding that attribute in that situation causes the duplication.

These are the exact settings I was currently testing at the time.

indent_with_tabs:true
indent_size:4
indent_char:" "
end_with_newline:true
extra_liners:Array[3]
0:"head"
1:"body"
2:"/html"
indent_handlebars:true
indent_inner_html:true
max_preserve_newlines:null
preserve_newlines:true
wrap_line_length:0
wrap_attributes:"auto"
content_unformatted:Array[25]
0:"area"
1:"base"
2:"br"
3:"col"
4:"embed"
5:"hr"
6:"img"
7:"input"
8:"keygen"
9:"link"
10:"menuitem"
11:"meta"
12:"param"
13:"source"
14:"track"
15:"wbr"
16:"!doctype"
17:"?xml"
18:"?php"
19:"?="
20:"basefont"
21:"isindex"
22:"pre"
23:"code"
24:"textarea"
@bitwiseman
Copy link
Member

bitwiseman commented Aug 13, 2018

Thanks for the feedback.

The key setting seems to be:

{
"content_unformatted": ["?php"]
}

If you remove that the issue goes away. Note: "content_unformatted" is not needed for "?php" elements as they have no elements. That is true for most of those.

But this is definitely a bug and it is great to get the feedback. We'll fix this ASAP.

@RiFi2k
Copy link
Author

RiFi2k commented Aug 13, 2018

Thanks for looking, sorry when I originally wrote this I didn't even see your last message. Your project is good stuff.

@bitwiseman
Copy link
Member

No, thank you for reporting the issue. It was important and I implemented a fix and released rc6 including a fix for this. Please report any issues, especially regressions you see in the future. 😄

@RiFi2k
Copy link
Author

RiFi2k commented Aug 13, 2018

On a side note now I can lose a lot of bloat in that array lol

@bitwiseman bitwiseman modified the milestones: v1.8.x, 1.8.0-rc7 Aug 14, 2018
@bitwiseman bitwiseman modified the milestones: 1.8.0-rc8, 1.8.0 Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants