curbengh / hexo-nofollow

Adds nofollow attribute to all external links in your hexo blog posts automatically.
MIT License
1 stars 0 forks source link

`</head><body>` tag in the wrong place #5

Closed SukkaW closed 4 years ago

SukkaW commented 4 years ago

When I use hexo-nofollow, the </head><body> tag will be placed in a wrong position like this:

image

When I use an older version of hexo-autonofollow, the problem disappear, the </head><body> will be in the right place.

The issue might related to https://github.com/cheeriojs/cheerio/issues/1031 , and could be solved by adding xmlMode: true in the cheerio.load config to avoid this.

https://github.com/curbengh/hexo-nofollow/blob/b91feb8d32ed3980f734dbb19f2a0f9885109936/lib/filter.js#L43-L45

curbengh commented 4 years ago

My (rough) understanding is that xmlMode is only intended for dealing with XML file/content. It can cause unintended result when using with HTML.

For example in a code block of xml code, notice the undesired blank lines below the codes when I enable xmlMode, xmlmode-true

It's back to normal once I disable xmlMode, xmlmode-false

I noticed that issue before, but couldn't reproduce reliably. Do you have sample repo that I can test?

You could also try the v2.0 branch which includes https://github.com/cheeriojs/dom-serializer/pull/85, but it's not directly related to the issue.