Giter Site home page Giter Site logo

Comments (6)

JonathanMagnan avatar JonathanMagnan commented on May 27, 2024 1

Hello @mems ,

We have released today the v1.11.55: https://github.com/zzzprojects/html-agility-pack/releases/tag/v1.11.55

You can see this commit that will explain what we did:

In this version:

  • If a comment is provided without being enclosed with <-- and -->, we will add it to the comment (with a space before and after. So doc.CreateComment(" cde "); will create the following comment: <-- cde --> as you explicitly specified to add a additional space before and after the text.
  • To be somewhat backward compatible, if the comment stored is already <-- and -->, we will no longer enclose it with an extra <!-- and -->.
  • When writing a comment with the WriteTo method, we will no longer add an extra space at the end before the -->

You can see the following Fiddle with your case on this new version: https://dotnetfiddle.net/6LvV3S

Which has the following output:

---- Test with outputAsXml = False ----
comment.OuterHtml = <!--  cde  -->
comment.WriteTo() = <!--  cde  -->
comment2.OuterHtml = <!-- fgh -->
commen2t.WriteTo() = <!-- fgh -->
doc.DocumentNode.OuterHtml = <!-- abc --><!--  cde  --><!-- fgh -->
doc.DocumentNode.WriteTo() = <!-- abc --><!--  cde  --><!-- fgh -->
---- Test with outputAsXml = True ----
comment.OuterHtml = <!--  cde  -->
comment.WriteTo() = <!--  cde  -->
comment2.OuterHtml = <!-- fgh -->
commen2t.WriteTo() = <!-- fgh -->
doc.DocumentNode.OuterHtml = <?xml version="1.0" encoding="iso-8859-1"?><span><!-- abc --><!--  cde  --><!-- fgh --></span>
doc.DocumentNode.WriteTo() = <?xml version="1.0" encoding="iso-8859-1"?><span><!-- abc --><!--  cde  --><!-- fgh --></span>

Let me know if we missing something.

Best Regards,

Jon

from html-agility-pack.

JonathanMagnan avatar JonathanMagnan commented on May 27, 2024 1

Hello @mems ,

Just to let you know that the merge from @elgonzo has been merged (thank again!). So, no additional space will be added anymore when creating the comment tag manually.

Best Regards,

Jon

from html-agility-pack.

JonathanMagnan avatar JonathanMagnan commented on May 27, 2024

Hello @mems ,

Thank you for reporting. Indeed something doesn't work in this logic.

We will look at it.

Best Regards,

Jon

from html-agility-pack.

elgonzo avatar elgonzo commented on May 27, 2024

@JonathanMagnan,

please note that the code in HtmlDocument.cs adds surrounding spaces to the comment, something it should not do. Instead of "<!-- " and " -->", it should use "<!--" and "-->" without the spaces. (The code in HtmlNode.cs and HtmlCommentNode.cs appear to do it correctly.)

EDIT: I made a pull request for this: #528

from html-agility-pack.

JonathanMagnan avatar JonathanMagnan commented on May 27, 2024

Thank you @elgonzo ,

I understand your point.

Adding a space before and after is usually a good practice. It is our responsibility? Probably not and like @mems did in his example, he added the space on his side.

So we will probably go ahead with your pull ;)

from html-agility-pack.

mems avatar mems commented on May 27, 2024

Since there is a release version that fix my issue, I close it now.

Thank you @JonathanMagnan

from html-agility-pack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.