Comments (6)
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. Sodoc.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.
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.
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.
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.
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.
Since there is a release version that fix my issue, I close it now.
Thank you @JonathanMagnan
from html-agility-pack.
Related Issues (20)
- update System.Net.Http to 4.3.4 HOT 2
- The html rendering result is different from the html output result HOT 5
- The html rendering result is different from the html output result when tbody is added inside unclosed th HOT 3
- After applying HAP1.11.57, InnerText cannot be obtained correctly. HOT 11
- (2) The html rendering result is different from the html output result HOT 4
- Can't find a node with a long id HOT 1
- it happened again after a Rolled back to version HtmlAgilityPack 1.11.50, then again to HtmlAgilityPack 1.11.57 and it worked. HOT 2
- Can't find a node used HtmlAgilityPack 1.11.57 HOT 2
- How to make the DocumentNode.SelectNodes(XPath) for both text and img content together in the correct sequence? HOT 3
- ??? HOT 2
- Double <p> <p> open tags leave one <p> open even with option setted HOT 6
- The html rendering result is different from the html output result when we have two unclosed tbody tags HOT 2
- When we have a closing tag before the current open tag is closed we have different results between HAP and Chrome rendering
- The formatting is a bit interesting HOT 1
- Set PackageLicenseExpression on nuget HOT 5
- page source code HOT 19
- [HtmlAgilityPack version 1.11.60] request: add HtmlWeb Load() exception HOT 5
- bug: SelectSingleNode not returning anything HOT 7
- Modify a `#text` node name causes a `StackOverflowException` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html-agility-pack.