Giter Site home page Giter Site logo

插件将所有文本全部转换成了html实体编码。plugin transfers all text to HTML entity coding. about hexo-filter-github-emojis HOT 14 CLOSED

crimx avatar crimx commented on May 25, 2024
插件将所有文本全部转换成了html实体编码。plugin transfers all text to HTML entity coding.

from hexo-filter-github-emojis.

Comments (14)

CoreJa avatar CoreJa commented on May 25, 2024 2

const $ = cheerio.load(data.content)改为const $ = cheerio.load(data.content,{decodeEntities: false})
jquery拿到的元素则没有做html实体编码。

目前测试是没有太大问题。我会再检查一下,没有问题后给你提个pr。
谢谢大佬帮助!

from hexo-filter-github-emojis.

crimx avatar crimx commented on May 25, 2024

你好,确定是这个插件的问题吗?据我所知这个插件没有做这样的替换。

from hexo-filter-github-emojis.

CoreJa avatar CoreJa commented on May 25, 2024

确定,因为当我config下不启用这个插件的时候就没有问题了。我刚刚把插件关了并clean后重新deploy到服务器,没有出现描述的问题。

from hexo-filter-github-emojis.

crimx avatar crimx commented on May 25, 2024

这可能是跟某个插件冲突了,或者是文本编码的问题?很可能跟这里有关

const $ = cheerio.load(data.content)

因为我现在不用 Hexo 了,之前的博客也没出现这样的问题,所以就不去折腾你的环境了。你可以提 PR 修复或者去掉本插件。

from hexo-filter-github-emojis.

CoreJa avatar CoreJa commented on May 25, 2024

好的谢谢大佬。刚刚在调试此插件,的确会将文本变成编码。我如果发现问题了再提个pr。

from hexo-filter-github-emojis.

CoreJa avatar CoreJa commented on May 25, 2024

刚刚调试的时候发现cheerio拿到的data.content是正常的。在replaceColons($('body')[0], $, emojis)调用的时候出现问题。然后data被放回了全都编码了的content。
目前猜测和data['no-emoji']有关,因为返回的是undefined

from hexo-filter-github-emojis.

CoreJa avatar CoreJa commented on May 25, 2024

如果可以的话,想请教一下data['no-emoji']是怎样使用的
目前调试的过程中以下两处判断均不符合预期。

if (!options.inject && data['no-emoji']) { return data }

这行的目的应该是判断文章是否含有emoji,对没有emoji的文章直接跳过。而在处理一篇我确定没有emoji字符的文章里它仍然返回true并进行了处理。
if (!data['no-emoji']) {

同上。

from hexo-filter-github-emojis.

crimx avatar crimx commented on May 25, 2024

啊,那应该冲突是在这里了

if (content !== child.data) {
$(child).replaceWith($.parseHTML(content))
}

对比你的搜索插件生成的 HTML 。

no-emoji 那个见文档,是一项 front matter 选项,跟这里无关。

from hexo-filter-github-emojis.

CoreJa avatar CoreJa commented on May 25, 2024

呃的确是这个问题,no-emoji是我没注意。的确是替换出了问题。
不过我留意到

if (!data['no-emoji']) {
replaceColons($('body')[0], $, emojis)
}
data.content = $('body').html()
return data

这一段即使没有进入到replaceColons($('body')[0], $, emojis)方法之前,$('body').html()在控制台的输出也是html实体编码。

from hexo-filter-github-emojis.

crimx avatar crimx commented on May 25, 2024

那就是前面第一段 cheerio.load 出的问题咯

from hexo-filter-github-emojis.

crimx avatar crimx commented on May 25, 2024

我还是倾向你的 HTML 文本编码在这里产生了冲突,可以检查一下 cheeriojs/cheerio#866

from hexo-filter-github-emojis.

CoreJa avatar CoreJa commented on May 25, 2024

你是对的,cheerio上issue和我的情况一样。

from hexo-filter-github-emojis.

CoreJa avatar CoreJa commented on May 25, 2024

#18
感谢大佬指点,话说npm那边是实时更新的吗还是得等一段时间?

from hexo-filter-github-emojis.

crimx avatar crimx commented on May 25, 2024

已发布

from hexo-filter-github-emojis.

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.