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

fix: compatibility with cheerio 1.0.0+ (#3313) #3315

Merged
merged 3 commits into from Oct 28, 2018

Conversation

4 participants
@curbengh
Copy link
Contributor

commented Oct 27, 2018

Fix #3313. Related to #3129.

  1. When a third-party plugin uses cheerio 1.0.0-rc.1+, <html><head><body> are automatically added to every empty or open tag (see cheeriojs/cheerio#1031 cheeriojs/cheerio#1239). If I have <p>, it will results in,
<html><head></head><body><p></body></html>
  1. meta_generator.js prepend meta generator tag to every <head>. e.g.
<html><head><meta name="generator"...></head><body><p></body></html>
  1. Those extra <html><head><body> are stripped away in the final $.html(), leaving
<meta name="generator"...><p>

As a workaround, meta_generator.js prepend only to non-empty real <head>. I assume Hexo page has at least meta charset or css in the <head>.

Without this workaround, if I use any plugin that uses cheerio 1.0.0+ (e.g. hexo-nofollow), meta_generator will also prepend tag to <body> (see curbengh/hexo-testing@f4824bb).

Thank you for creating a pull request to contribute to Hexo code! Before you open the request please review the following guidelines and tips to help it be more easily integrated:

  • Add test cases for the changes.
  • Passed the CI test.

cc @h404bi

@curbengh curbengh changed the title fix: compatibility with cheerio 1.0.0+ #3313 fix: compatibility with cheerio 1.0.0+ (#3313) Oct 27, 2018

@coveralls

This comment has been minimized.

Copy link

commented Oct 27, 2018

Coverage Status

Coverage remained the same at 97.27% when pulling 4d071c4 on weyusi:fix-meta into bbc2f04 on hexojs:master.

@h404bi
Copy link
Contributor

left a comment

LGTM

@curbengh

This comment has been minimized.

Copy link
Contributor Author

commented Oct 28, 2018

I should create a test case, learning...

Edit: Added a test case.

@curbengh curbengh force-pushed the curbengh:fix-meta branch from 348f639 to 96595e4 Oct 28, 2018

weyusi

@curbengh curbengh force-pushed the curbengh:fix-meta branch from 82c4d3e to 0fbdeda Oct 28, 2018

@@ -0,0 +1,28 @@
'use strict';

const should = require('chai').should(); // eslint-disable-line

This comment has been minimized.

Copy link
@YoshinoriN

YoshinoriN Oct 28, 2018

Member

We were changed to use globally chai.should in this commit.
So, no need this line.

This comment has been minimized.

Copy link
@curbengh

curbengh Oct 28, 2018

Author Contributor

Addressed

const should = require('chai').should(); // eslint-disable-line

describe('Meta Generator', function() {
const Hexo = require('../../../lib/hexo');

This comment has been minimized.

Copy link
@YoshinoriN

YoshinoriN Oct 28, 2018

Member

Now, We are migrating hexo code to ES6 syntax.
Would you please change to arrow function ? Also others.

This comment has been minimized.

Copy link
@curbengh

curbengh Oct 28, 2018

Author Contributor

Addressed

@YoshinoriN

This comment has been minimized.

Copy link
Member

commented Oct 28, 2018

Other implementation and test code I will review later.
Thanks !!

weyusi

@YoshinoriN YoshinoriN merged commit 51808d5 into hexojs:master Oct 28, 2018

4 checks passed

codeclimate All good!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 97.27%
Details
@YoshinoriN

This comment has been minimized.

Copy link
Member

commented Oct 28, 2018

LGTM! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.