-
-
Notifications
You must be signed in to change notification settings - Fork 380
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
OptionOutputAsXml adds spaces to comments when using InnerHtml #412
Comments
Hello @spassarop , He looked at this issue and here is the line that causes it: https://github.com/zzzprojects/html-agility-pack/blob/master/src/HtmlAgilityPack.Shared/HtmlNode.cs#L1830 It seems that comment, when The fix is easy but one problem I have is the |
Well, that's a shame. I wouldn't like to use my own version of the library as the update process would be tedious compared with just updating a Nugget package. I guess my only option is doing that if I want to keep using HAP, unless you have a workaround in mind. Close the issue if that's not the case. Thanks for your time. |
As said, I don't think changing the default behavior is a good thing since this library is so much used (We did it a few times in the past and every time a few days later, multiple people were reporting that their projects were no longer working). However, I asked my developer to check a little bit more this week to check if we can add an option to better manage it. |
I understand, I know backward compatibility is hard to maintain and usually there is a trade-off on fixing or keeping an issue. Again, thank you very much for your time :) |
Hello @spassarop , A new version has been released with the option Let me know if that's exactly what you were looking for. Since that's a new option, this is still time to improve it without impacting anyone. |
Hello @JonathanMagnan, That option actually works and yes, it was exacly what I was looking for, keeping comments unchanged. Thanks to the team! |
Description
I have some cases with HTML comments which I need to preserve their syntax. Some HTML examples can be modified (by changing the
Comment
property on aHtmlCommentNode
). When I setOptionOutputAsXml
totrue
, spaces are always added on different places.In the fiddle I provide below I have a working example of the issue. This are my basic cases:
<div>text <!-- comment --></div>
<div>text <!-- comment --></div>
<div>text <!--[if IE]> <!--[if gte 6]> comment <[endif]--><[endif]--></div>
<div>text <!--[if IE]> <! - -[if gte 6]> comment <[endif] --><[endif]--></div>
For the first row case: A space has been added after "comment", now having two spaces.
For the second row case: Two spaces have been added on the second "<!--" and one after the first "[endif]".
Reading the code and changing options that don't conflict with my needs took me to no solution, also I don't understand why this could be normal behavior. That's why I'm creating this issue.
Fiddle
Custom Fiddle to reproduce the issue: https://dotnetfiddle.net/TkTqt0
Further technical details
I hope there is a solution I'm not seeing or, if this is a real issue, it's easy to solve and could be included in the next release.
Thank you in advance.
The text was updated successfully, but these errors were encountered: