jquery - 发出 JQuery 异常的 Hugo Markdown 脚注
问题描述
我有一个 Hugo 网站,其中包含指定脚注的 Markdown 内容。该站点包括 JQuery 3.4.1。
单击脚注锚点时,控制台中会发出 JQuery 异常:
Uncaught Error: Syntax error, unrecognized expression: [name=fn:1]
at Function.se.error (jquery-3.4.1.min.js:2)
at se.tokenize (jquery-3.4.1.min.js:2)
at se.select (jquery-3.4.1.min.js:2)
at Function.se [as find] (jquery-3.4.1.min.js:2)
at k.fn.init.find (jquery-3.4.1.min.js:2)
at new k.fn.init (jquery-3.4.1.min.js:2)
at k (jquery-3.4.1.min.js:2)
at HTMLAnchorElement.<anonymous> ((index):255)
at HTMLAnchorElement.dispatch (jquery-3.4.1.min.js:2)
at HTMLAnchorElement.v.handle (jquery-3.4.1.min.js:2)
为脚注链接生成的 HTML 代码如下所示:
<sup id="fnref:1">
<a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a>
</sup>
为脚注生成的 HTML 代码如下所示:
<section class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1" role="doc-endnote">
<p>
<a href="https://en.wikipedia.org/wiki/Pineapple">Pineapple</a>
<a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a>
</p>
</li>
</ol>
</section>
对我来说,这看起来像是标准的 HTML。为什么 JQuery 会抛出异常?
解决方案
我将问题追溯到我也在使用Smooth Scrolling CSS Trick的事实。
生成的代码使用ids 作为锚点,但平滑滚动代码不处理它。
推荐阅读
- c# - 是否有一个输入传递给 n 个方法的设计模式,每个方法返回下一个方法的输入
- r - summary()与glance()之间的p值差异?
- c# - 调用在另一个线程上运行的方法
- jsp - 如何创建定义变量的迭代标记处理程序
- python - Return 语句打印第一次迭代,而 Print 输出所有迭代 - Python
- ssl - 对等连接中的 TLS
- python-3.x - Python If 语句未按预期工作
- python - Scrapy 与多个 Selenium 实例(并行)
- javascript - 未使用 AdvancedCustomFields 设置 Google Maps API 密钥
- java - 埃拉托色尼平行筛的性能