Jekyll_Word_Counter

Jekyll_Word_Counter

This script won't calculate links and references

Jekyll_Word_Counter

This script won't calculate links and references

Liquid自带的number_of_words经常会计算大量的参考文献和链接,而且GitHub Pages的Jekyll版本是3.x,不支持number_of_words: "auto",所以自己写了一个

核心是let web = '{{- page.content | strip_html | escape_once | compact | strip -}}';将Liquid页面内容安全地赋予JavaScrip变量,之后正则就好

文献匹配按照自己手头的几个文献测试的正则,个别没有doi/arxiv的CNKI中文文献没有去除,防止影响正文内容(毕竟几乎不看CNKI)

如有遗漏的标点符号烦请提醒我补充,中英文各种符号确实挺乱的

写的比较混乱,见谅


食用方法 将代码复制到需要字数统计的html页面/模板中 Word Count: 为字数统计显示的行,“Word Count”随意替换

丢同一html后面就好