其他分享
首页 > 其他分享> > 在Hugo中优雅地使用数学公式

在Hugo中优雅地使用数学公式

作者:互联网

在2021年4月之前,我使用 Hexo 静态博客,也曾经因为 Hexo 默认的 Markdown 渲染引擎不能很好地渲染checkbox而头疼。现在,切换到 Hugo 以后,有一次遇到了数学公式渲染的问题。

关于 Hugo 默认的 Markdown 渲染引擎goldmark,在官方文档1中可以看到:

markup:
asciidocExt:
attributes: {}
backend: html5
extensions: []
failureLevel: fatal
noHeaderOrFooter: true
preserveTOC: false
safeMode: unsafe
sectionNumbers: false
trace: false
verbose: false
workingFolderCurrent: false
blackFriday:
angledQuotes: false
extensions: null
extensionsMask: null
footnoteAnchorPrefix: “”
footnoteReturnLinkContents: “”
fractions: true
hrefTargetBlank: false
latexDashes: true
nofollowLinks: false
noreferrerLinks: false
plainIDAnchors: true
skipHTML: false
smartDashes: true
smartypants: true
smartypantsQuotesNBSP: false
taskLists: true
defaultMarkdownHandler: goldmark
goldmark:
extensions:
definitionList: true
footnote: true
linkify: true
strikethrough: true
table: true
taskList: true
typographer: true
parser:
attribute:
block: false
title: true
autoHeadingID: true
autoHeadingIDType: github
renderer:
hardWraps: false
unsafe: false
xhtml: false
highlight:
anchorLineNos: false
codeFences: true
guessSyntax: false
hl_Lines: “”
lineAnchors: “”
lineNoStart: 1
lineNos: false
lineNumbersInTable: true
noClasses: true
style: monokai
tabWidth: 4
tableOfContents:
endLevel: 3
ordered: false
startLevel: 2
后来因为goldmark对 HTML 渲染的效果不是很满意,故修改为blackfriday。关于blackfriday,可以参考一份写的比较完善,可读性又比较强的Hugo中文文档2

至于引入对MathJax的支持(MathJax兼容Latex),需要在 HTML 模板文件中引入相应的 JS 代码:

一些好用的数学工具:

原文链接:https://byteprince.com/posts/2d4e6e67/

标签:数学公式,false,渲染,Hugo,优雅,extensions,goldmark,true
来源: https://blog.csdn.net/weixin_42083728/article/details/120257242