feat(math): more block delimiter for math and update katex 0.11.1 -> 0.15.3
This commit is contained in:
@@ -36,13 +36,13 @@ libFiles:
|
|||||||
sharerJS: sharer.js@0.4.0/sharer.min.js
|
sharerJS: sharer.js@0.4.0/sharer.min.js
|
||||||
# typeit@7.0.4 https://github.com/alexmacarthur/typeit
|
# typeit@7.0.4 https://github.com/alexmacarthur/typeit
|
||||||
typeitJS: typeit@7.0.4/dist/typeit.min.js
|
typeitJS: typeit@7.0.4/dist/typeit.min.js
|
||||||
# katex@0.11.1 https://katex.org/
|
# katex@0.15.3 https://katex.org/
|
||||||
katexCSS: katex@0.11.1/dist/katex.min.css
|
katexCSS: katex@0.15.3/dist/katex.min.css
|
||||||
katexJS: katex@0.11.1/dist/katex.min.js
|
katexJS: katex@0.15.3/dist/katex.min.js
|
||||||
katexAutoRenderJS: katex@0.11.1/dist/contrib/auto-render.min.js
|
katexAutoRenderJS: katex@0.15.3/dist/contrib/auto-render.min.js
|
||||||
katexCopyTexCSS: katex@0.11.1/dist/contrib/copy-tex.min.css
|
katexCopyTexCSS: katex@0.15.3/dist/contrib/copy-tex.min.css
|
||||||
katexCopyTexJS: katex@0.11.1/dist/contrib/copy-tex.min.js
|
katexCopyTexJS: katex@0.15.3/dist/contrib/copy-tex.min.js
|
||||||
katexMhchemJS: katex@0.11.1/dist/contrib/mhchem.min.js
|
katexMhchemJS: katex@0.15.3/dist/contrib/mhchem.min.js
|
||||||
# mermaid@8.5.1 https://github.com/knsv/mermaid
|
# mermaid@8.5.1 https://github.com/knsv/mermaid
|
||||||
mermaidJS: mermaid@8.5.1/dist/mermaid.min.js
|
mermaidJS: mermaid@8.5.1/dist/mermaid.min.js
|
||||||
# echarts@4.8.0 https://echarts.apache.org/
|
# echarts@4.8.0 https://echarts.apache.org/
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ lg-zoom.js@1.2.0 https://github.com/sachinchoolur/lg-zoom.js
|
|||||||
clipboard.js@2.0.6 https://github.com/zenorocha/clipboard.js
|
clipboard.js@2.0.6 https://github.com/zenorocha/clipboard.js
|
||||||
sharer.js@0.4.0 https://github.com/ellisonleao/sharer.js
|
sharer.js@0.4.0 https://github.com/ellisonleao/sharer.js
|
||||||
typeit@7.0.4 https://github.com/alexmacarthur/typeit
|
typeit@7.0.4 https://github.com/alexmacarthur/typeit
|
||||||
katex@0.11.1 https://katex.org/
|
katex@0.15.3 https://katex.org/
|
||||||
mermaid@8.5.1 https://github.com/knsv/mermaid
|
mermaid@8.5.1 https://github.com/knsv/mermaid
|
||||||
echarts@4.8.0 https://echarts.apache.org/
|
echarts@4.8.0 https://echarts.apache.org/
|
||||||
mapbox-gl@1.10.1 https://github.com/mapbox/mapbox-gl-js
|
mapbox-gl@1.10.1 https://github.com/mapbox/mapbox-gl-js
|
||||||
|
|||||||
2
assets/lib/katex/auto-render.min.js
vendored
Executable file → Normal file
2
assets/lib/katex/auto-render.min.js
vendored
Executable file → Normal file
@@ -1 +1 @@
|
|||||||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("katex")):"function"==typeof define&&define.amd?define(["katex"],t):"object"==typeof exports?exports.renderMathInElement=t(require("katex")):e.renderMathInElement=t(e.katex)}("undefined"!=typeof self?self:this,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),a=function(e,t,r){for(var n=r,o=0,a=e.length;n<t.length;){var i=t[n];if(o<=0&&t.slice(n,n+a)===e)return n;"\\"===i?n++:"{"===i?o++:"}"===i&&o--,n++}return-1},i=function(e,t,r,n){for(var o=[],i=0;i<e.length;i++)if("text"===e[i].type){var l=e[i].data,d=!0,s=0,f=void 0;for(-1!==(f=l.indexOf(t))&&(s=f,o.push({type:"text",data:l.slice(0,s)}),d=!1);;){if(d){if(-1===(f=l.indexOf(t,s)))break;o.push({type:"text",data:l.slice(s,f)}),s=f}else{if(-1===(f=a(r,l,s+t.length)))break;o.push({type:"math",data:l.slice(s+t.length,f),rawData:l.slice(s,f+r.length),display:n}),s=f+r.length}d=!d}o.push({type:"text",data:l.slice(s)})}else o.push(e[i]);return o},l=function(e,t){for(var r=function(e,t){for(var r=[{type:"text",data:e}],n=0;n<t.length;n++){var o=t[n];r=i(r,o.left,o.right,o.display||!1)}return r}(e,t.delimiters),n=document.createDocumentFragment(),a=0;a<r.length;a++)if("text"===r[a].type)n.appendChild(document.createTextNode(r[a].data));else{var l=document.createElement("span"),d=r[a].data;t.displayMode=r[a].display;try{t.preProcess&&(d=t.preProcess(d)),o.a.render(d,l,t)}catch(e){if(!(e instanceof o.a.ParseError))throw e;t.errorCallback("KaTeX auto-render: Failed to parse `"+r[a].data+"` with ",e),n.appendChild(document.createTextNode(r[a].rawData));continue}n.appendChild(l)}return n};t.default=function(e,t){if(!e)throw new Error("No element provided to render");var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);r.delimiters=r.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\[",right:"\\]",display:!0}],r.ignoredTags=r.ignoredTags||["script","noscript","style","textarea","pre","code"],r.ignoredClasses=r.ignoredClasses||[],r.errorCallback=r.errorCallback||console.error,r.macros=r.macros||{},function e(t,r){for(var n=0;n<t.childNodes.length;n++){var o=t.childNodes[n];if(3===o.nodeType){var a=l(o.textContent,r);n+=a.childNodes.length-1,t.replaceChild(a,o)}else 1===o.nodeType&&function(){var t=" "+o.className+" ";-1===r.ignoredTags.indexOf(o.nodeName.toLowerCase())&&r.ignoredClasses.every(function(e){return-1===t.indexOf(" "+e+" ")})&&e(o,r)}()}}(e,r)}}]).default});
|
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("katex")):"function"==typeof define&&define.amd?define(["katex"],t):"object"==typeof exports?exports.renderMathInElement=t(require("katex")):e.renderMathInElement=t(e.katex)}("undefined"!=typeof self?self:this,(function(e){return function(){"use strict";var t={771:function(t){t.exports=e}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var a={};return function(){n.d(a,{default:function(){return s}});var e=n(771),t=n.n(e),r=function(e,t,r){for(var n=r,a=0,i=e.length;n<t.length;){var o=t[n];if(a<=0&&t.slice(n,n+i)===e)return n;"\\"===o?n++:"{"===o?a++:"}"===o&&a--,n++}return-1},i=/^\\begin{/,o=function(e,t){for(var n,a=[],o=new RegExp("("+t.map((function(e){return e.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")})).join("|")+")");-1!==(n=e.search(o));){n>0&&(a.push({type:"text",data:e.slice(0,n)}),e=e.slice(n));var l=t.findIndex((function(t){return e.startsWith(t.left)}));if(-1===(n=r(t[l].right,e,t[l].left.length)))break;var d=e.slice(0,n+t[l].right.length),s=i.test(d)?d:e.slice(t[l].left.length,n);a.push({type:"math",data:s,rawData:d,display:t[l].display}),e=e.slice(n+t[l].right.length)}return""!==e&&a.push({type:"text",data:e}),a},l=function(e,r){var n=o(e,r.delimiters);if(1===n.length&&"text"===n[0].type)return null;for(var a=document.createDocumentFragment(),i=0;i<n.length;i++)if("text"===n[i].type)a.appendChild(document.createTextNode(n[i].data));else{var l=document.createElement("span"),d=n[i].data;r.displayMode=n[i].display;try{r.preProcess&&(d=r.preProcess(d)),t().render(d,l,r)}catch(e){if(!(e instanceof t().ParseError))throw e;r.errorCallback("KaTeX auto-render: Failed to parse `"+n[i].data+"` with ",e),a.appendChild(document.createTextNode(n[i].rawData));continue}a.appendChild(l)}return a},d=function e(t,r){for(var n=0;n<t.childNodes.length;n++){var a=t.childNodes[n];if(3===a.nodeType){var i=l(a.textContent,r);i&&(n+=i.childNodes.length-1,t.replaceChild(i,a))}else 1===a.nodeType&&function(){var t=" "+a.className+" ";-1===r.ignoredTags.indexOf(a.nodeName.toLowerCase())&&r.ignoredClasses.every((function(e){return-1===t.indexOf(" "+e+" ")}))&&e(a,r)}()}},s=function(e,t){if(!e)throw new Error("No element provided to render");var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);r.delimiters=r.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],r.ignoredTags=r.ignoredTags||["script","noscript","style","textarea","pre","code","option"],r.ignoredClasses=r.ignoredClasses||[],r.errorCallback=r.errorCallback||console.error,r.macros=r.macros||{},d(e,r)}}(),a=a.default}()}));
|
||||||
2
assets/lib/katex/copy-tex.min.css
vendored
2
assets/lib/katex/copy-tex.min.css
vendored
@@ -1 +1 @@
|
|||||||
.katex,.katex-display{user-select:all;-moz-user-select:all;-webkit-user-select:all;-ms-user-select:all}
|
.katex,.katex-display{-webkit-user-select:all;-moz-user-select:all;user-select:all}
|
||||||
|
|||||||
2
assets/lib/katex/copy-tex.min.js
vendored
2
assets/lib/katex/copy-tex.min.js
vendored
@@ -1 +1 @@
|
|||||||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){},function(e,t,n){"use strict";n.r(t);n(0);var r={inline:["$","$"],display:["$$","$$"]},o=function(e,t){void 0===t&&(t=r);for(var n=e.querySelectorAll(".katex-mathml + .katex-html"),o=0;o<n.length;o++){var l=n[o];l.remove?l.remove(null):l.parentNode.removeChild(l)}for(var i=e.querySelectorAll(".katex-mathml"),a=0;a<i.length;a++){var u=i[a],f=u.querySelector("annotation");f&&(u.replaceWith?u.replaceWith(f):u.parentNode.replaceChild(f,u),f.innerHTML=t.inline[0]+f.innerHTML+t.inline[1])}for(var c=e.querySelectorAll(".katex-display annotation"),d=0;d<c.length;d++){var p=c[d];p.innerHTML=t.display[0]+p.innerHTML.substr(t.inline[0].length,p.innerHTML.length-t.inline[0].length-t.inline[1].length)+t.display[1]}return e};document.addEventListener("copy",function(e){var t=window.getSelection();if(!t.isCollapsed){var n=t.getRangeAt(0).cloneContents();if(n.querySelector(".katex-mathml")){for(var r=[],l=0;l<n.childNodes.length;l++)r.push(n.childNodes[l].outerHTML);e.clipboardData.setData("text/html",r.join("")),e.clipboardData.setData("text/plain",o(n).textContent),e.preventDefault()}}})}]).default});
|
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var l in n)("object"==typeof exports?exports:e)[l]=n[l]}}("undefined"!=typeof self?self:this,(function(){return function(){"use strict";var e={},t={inline:["$","$"],display:["$$","$$"]},n=function(e,n){void 0===n&&(n=t);for(var l=e.querySelectorAll(".katex-mathml + .katex-html"),r=0;r<l.length;r++){var i=l[r];i.remove?i.remove(null):i.parentNode.removeChild(i)}for(var o=e.querySelectorAll(".katex-mathml"),a=0;a<o.length;a++){var d=o[a],f=d.querySelector("annotation");f&&(d.replaceWith?d.replaceWith(f):d.parentNode.replaceChild(f,d),f.innerHTML=n.inline[0]+f.innerHTML+n.inline[1])}for(var c=e.querySelectorAll(".katex-display annotation"),s=0;s<c.length;s++){var p=c[s];p.innerHTML=n.display[0]+p.innerHTML.substr(n.inline[0].length,p.innerHTML.length-n.inline[0].length-n.inline[1].length)+n.display[1]}return e};return document.addEventListener("copy",(function(e){var t=window.getSelection();if(!t.isCollapsed){var l=t.getRangeAt(0).cloneContents();if(l.querySelector(".katex-mathml")){for(var r=[],i=0;i<l.childNodes.length;i++)r.push(l.childNodes[i].outerHTML);e.clipboardData.setData("text/html",r.join("")),e.clipboardData.setData("text/plain",n(l).textContent),e.preventDefault()}}})),e=e.default}()}));
|
||||||
2
assets/lib/katex/katex.min.css
vendored
Executable file → Normal file
2
assets/lib/katex/katex.min.css
vendored
Executable file → Normal file
File diff suppressed because one or more lines are too long
2
assets/lib/katex/katex.min.js
vendored
Executable file → Normal file
2
assets/lib/katex/katex.min.js
vendored
Executable file → Normal file
File diff suppressed because one or more lines are too long
2
assets/lib/katex/mhchem.min.js
vendored
2
assets/lib/katex/mhchem.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -579,14 +579,14 @@ enableEmoji = true
|
|||||||
# KaTeX 数学公式配置 (KaTeX https://katex.org/)
|
# KaTeX 数学公式配置 (KaTeX https://katex.org/)
|
||||||
[params.page.math]
|
[params.page.math]
|
||||||
enable = false
|
enable = false
|
||||||
# default block delimiter is $$ ... $$ and \\[ ... \\]
|
# default inline delimiter is $ ... $ and \( ... \)
|
||||||
# 默认块定界符是 $$ ... $$ 和 \\[ ... \\]
|
# 默认行内定界符是 $ ... $ 和 \( ... \)
|
||||||
blockLeftDelimiter = ""
|
|
||||||
blockRightDelimiter = ""
|
|
||||||
# default inline delimiter is $ ... $ and \\( ... \\)
|
|
||||||
# 默认行内定界符是 $ ... $ 和 \\( ... \\)
|
|
||||||
inlineLeftDelimiter = ""
|
inlineLeftDelimiter = ""
|
||||||
inlineRightDelimiter = ""
|
inlineRightDelimiter = ""
|
||||||
|
# default block delimiter is $$ ... $$, \[ ... \], \begin{equation} ... \end{equation} and some other functions
|
||||||
|
# 默认块定界符是 $$ ... $$, \[ ... \], \begin{equation} ... \end{equation} 和一些其它的函数
|
||||||
|
blockLeftDelimiter = ""
|
||||||
|
blockRightDelimiter = ""
|
||||||
# KaTeX extension copy_tex
|
# KaTeX extension copy_tex
|
||||||
# KaTeX 插件 copy_tex
|
# KaTeX 插件 copy_tex
|
||||||
copyTex = true
|
copyTex = true
|
||||||
|
|||||||
@@ -432,12 +432,12 @@ Please open the code block below to view the complete sample configuration :(far
|
|||||||
# {{< version 0.2.0 changed >}} {{< link "https://katex.org/" KaTeX >}} mathematical formulas
|
# {{< version 0.2.0 changed >}} {{< link "https://katex.org/" KaTeX >}} mathematical formulas
|
||||||
[params.page.math]
|
[params.page.math]
|
||||||
enable = true
|
enable = true
|
||||||
# default block delimiter is $$ ... $$ and \\[ ... \\]
|
# default inline delimiter is $ ... $ and \( ... \)
|
||||||
blockLeftDelimiter = ""
|
|
||||||
blockRightDelimiter = ""
|
|
||||||
# default inline delimiter is $ ... $ and \\( ... \\)
|
|
||||||
inlineLeftDelimiter = ""
|
inlineLeftDelimiter = ""
|
||||||
inlineRightDelimiter = ""
|
inlineRightDelimiter = ""
|
||||||
|
# default block delimiter is $$ ... $$, \[ ... \], \begin{equation} ... \end{equation} and some other functions
|
||||||
|
blockLeftDelimiter = ""
|
||||||
|
blockRightDelimiter = ""
|
||||||
# KaTeX extension copy_tex
|
# KaTeX extension copy_tex
|
||||||
copyTex = true
|
copyTex = true
|
||||||
# KaTeX extension mhchem
|
# KaTeX extension mhchem
|
||||||
|
|||||||
@@ -441,12 +441,12 @@ hugo
|
|||||||
# {{< version 0.2.0 changed >}} {{< link "https://katex.org/" KaTeX >}} 数学公式
|
# {{< version 0.2.0 changed >}} {{< link "https://katex.org/" KaTeX >}} 数学公式
|
||||||
[params.page.math]
|
[params.page.math]
|
||||||
enable = true
|
enable = true
|
||||||
# 默认块定界符是 $$ ... $$ 和 \\[ ... \\]
|
# 默认行内定界符是 $ ... $ 和 \( ... \)
|
||||||
blockLeftDelimiter = ""
|
|
||||||
blockRightDelimiter = ""
|
|
||||||
# 默认行内定界符是 $ ... $ 和 \\( ... \\)
|
|
||||||
inlineLeftDelimiter = ""
|
inlineLeftDelimiter = ""
|
||||||
inlineRightDelimiter = ""
|
inlineRightDelimiter = ""
|
||||||
|
# 默认块定界符是 $$ ... $$, \[ ... \], \begin{equation} ... \end{equation} 和一些其它的函数
|
||||||
|
blockLeftDelimiter = ""
|
||||||
|
blockRightDelimiter = ""
|
||||||
# KaTeX 插件 copy_tex
|
# KaTeX 插件 copy_tex
|
||||||
copyTex = true
|
copyTex = true
|
||||||
# KaTeX 插件 mhchem
|
# KaTeX 插件 mhchem
|
||||||
|
|||||||
@@ -247,32 +247,38 @@ This part is shown in the [emoji support page](../emoji-support/).
|
|||||||
|
|
||||||
Set the property `enable = true` under `[params.math]` in your [site configuration](../theme-documentation-basics#site-configuration)
|
Set the property `enable = true` under `[params.math]` in your [site configuration](../theme-documentation-basics#site-configuration)
|
||||||
and the property `math: true` of the article front matter to enable the automatic rendering of mathematical formulas.
|
and the property `math: true` of the article front matter to enable the automatic rendering of mathematical formulas.
|
||||||
|
**$\KaTeX$** automatically renders formulas based on **specific delimiters**.
|
||||||
|
|
||||||
{{< admonition tip >}}
|
{{< admonition tip >}}
|
||||||
Here is a list of [$\TeX$ functions supported by $\KaTeX$](https://katex.org/docs/supported.html).
|
Here is a list of [$\TeX$ functions supported by $\KaTeX$](https://katex.org/docs/supported.html).
|
||||||
{{< /admonition >}}
|
{{< /admonition >}}
|
||||||
|
|
||||||
#### Block Formula
|
{{< admonition >}}
|
||||||
|
Since Hugo generates HTML documents according to the syntax such as `_`/`*`/`>>` when rendering Markdown documents,
|
||||||
|
and some text content in the form of escape characters
|
||||||
|
(such as `\(`/`\)`/`\[`/`\]`/`\\`) escape processing will be performed automatically,
|
||||||
|
therefore, additional escape character expressions are required for these places to achieve automatic rendering:
|
||||||
|
|
||||||
The default block delimiters are `$$`/`$$` and `\\[`/`\\]`:
|
* `_` -> `\_`
|
||||||
|
* `*` -> `\*`
|
||||||
```markdown
|
* `>>` -> `\>>`
|
||||||
$$ c = \pm\sqrt{a^2 + b^2} $$
|
* `\(` -> `\\(`
|
||||||
|
* `\)` -> `\\)`
|
||||||
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
|
* `\[` -> `\\[`
|
||||||
```
|
* `\]` -> `\\]`
|
||||||
|
* `\\` -> `\\\\`
|
||||||
The rendered output looks like this:
|
{{< /admonition >}}
|
||||||
|
|
||||||
$$ c = \pm\sqrt{a^2 + b^2} $$
|
|
||||||
|
|
||||||
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
|
|
||||||
|
|
||||||
#### Inline Formula
|
#### Inline Formula
|
||||||
|
|
||||||
The default inline delimiters are `$`/`$` and `\\(`/`\\)`:
|
The default inline delimiters are:
|
||||||
|
|
||||||
```markdown
|
* `$ ... $`
|
||||||
|
* `\( ... \)` (escaped: `\\( ... \\)`)
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```tex
|
||||||
$c = \pm\sqrt{a^2 + b^2}$ and \\(f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi\\)
|
$c = \pm\sqrt{a^2 + b^2}$ and \\(f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi\\)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -280,8 +286,92 @@ The rendered output looks like this:
|
|||||||
|
|
||||||
$c = \pm\sqrt{a^2 + b^2}$ and \\(f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi\\)
|
$c = \pm\sqrt{a^2 + b^2}$ and \\(f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi\\)
|
||||||
|
|
||||||
|
#### Block Formula
|
||||||
|
|
||||||
|
The default block delimiters are:
|
||||||
|
|
||||||
|
* `$$ ... $$`
|
||||||
|
* `\[ ... \]` (escaped: `\\[ ... \\]`)
|
||||||
|
* `\begin{equation} ... \end{equation}` (unnumbered: `\begin{equation*} ... \end{equation*}`)
|
||||||
|
* `\begin{align} ... \end{align}` (unnumbered: `\begin{align*} ... \end{align*}`)
|
||||||
|
* `\begin{alignat} ... \end{alignat}` (unnumbered: `\begin{alignat*} ... \end{alignat*}`)
|
||||||
|
* `\begin{gather} ... \end{gather}` (unnumbered: `\begin{gather*} ... \end{gather*}`)
|
||||||
|
* `\begin{CD} ... \end{CD}`
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```tex
|
||||||
|
$$ c = \pm\sqrt{a^2 + b^2} $$
|
||||||
|
|
||||||
|
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
|
||||||
|
|
||||||
|
\begin{equation*}
|
||||||
|
\rho \frac{\mathrm{D} \mathbf{v}}{\mathrm{D} t}=\nabla \cdot \mathbb{P}+\rho \mathbf{f}
|
||||||
|
\end{equation*}
|
||||||
|
|
||||||
|
\begin{equation}
|
||||||
|
\mathbf{E}=\sum_{i} \mathbf{E}\_{i}=\mathbf{E}\_{1}+\mathbf{E}\_{2}+\mathbf{E}_{3}+\cdots
|
||||||
|
\end{equation}
|
||||||
|
|
||||||
|
\begin{align}
|
||||||
|
a&=b+c \\\\
|
||||||
|
d+e&=f
|
||||||
|
\end{align}
|
||||||
|
|
||||||
|
\begin{alignat}{2}
|
||||||
|
10&x+&3&y = 2 \\\\
|
||||||
|
3&x+&13&y = 4
|
||||||
|
\end{alignat}
|
||||||
|
|
||||||
|
\begin{gather}
|
||||||
|
a=b \\\\
|
||||||
|
e=b+c
|
||||||
|
\end{gather}
|
||||||
|
|
||||||
|
\begin{CD}
|
||||||
|
A @>a\>> B \\\\
|
||||||
|
@VbVV @AAcA \\\\
|
||||||
|
C @= D
|
||||||
|
\end{CD}
|
||||||
|
```
|
||||||
|
|
||||||
|
The rendered output looks like this:
|
||||||
|
|
||||||
|
$$ c = \pm\sqrt{a^2 + b^2} $$
|
||||||
|
|
||||||
|
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
|
||||||
|
|
||||||
|
\begin{equation*}
|
||||||
|
\rho \frac{\mathrm{D} \mathbf{v}}{\mathrm{D} t}=\nabla \cdot \mathbb{P}+\rho \mathbf{f}
|
||||||
|
\end{equation*}
|
||||||
|
|
||||||
|
\begin{equation}
|
||||||
|
\mathbf{E}=\sum_{i} \mathbf{E}\_{i}=\mathbf{E}\_{1}+\mathbf{E}\_{2}+\mathbf{E}_{3}+\cdots
|
||||||
|
\end{equation}
|
||||||
|
|
||||||
|
\begin{align}
|
||||||
|
a&=b+c \\\\
|
||||||
|
d+e&=f
|
||||||
|
\end{align}
|
||||||
|
|
||||||
|
\begin{alignat}{2}
|
||||||
|
10&x+&3&y = 2 \\\\
|
||||||
|
3&x+&13&y = 4
|
||||||
|
\end{alignat}
|
||||||
|
|
||||||
|
\begin{gather}
|
||||||
|
a=b \\\\
|
||||||
|
e=b+c
|
||||||
|
\end{gather}
|
||||||
|
|
||||||
|
\begin{CD}
|
||||||
|
A @>a\>> B \\\\
|
||||||
|
@VbVV @AAcA \\\\
|
||||||
|
C @= D
|
||||||
|
\end{CD}
|
||||||
|
|
||||||
{{< admonition tip >}}
|
{{< admonition tip >}}
|
||||||
You can add more block and inline delimiters in your [site configuration](../theme-documentation-basics#site-configuration).
|
You can add more inline and block delimiters in your [site configuration](../theme-documentation-basics#site-configuration).
|
||||||
{{< /admonition >}}
|
{{< /admonition >}}
|
||||||
|
|
||||||
#### Copy-tex
|
#### Copy-tex
|
||||||
@@ -292,7 +382,7 @@ By the extension, when selecting and copying $ \KaTeX $ rendered elements, copie
|
|||||||
|
|
||||||
Set the property `copyTex = true` under `[params.math]` in your [site configuration](../theme-documentation-basics#site-configuration) to enable Copy-tex.
|
Set the property `copyTex = true` under `[params.math]` in your [site configuration](../theme-documentation-basics#site-configuration) to enable Copy-tex.
|
||||||
|
|
||||||
Select and copy the formula rendered in the previous section, and you can find that the copied content is the LaTeX source code.
|
Select and copy the formula rendered in the previous section, and you can find that the copied content is the $\LaTeX$ source code.
|
||||||
|
|
||||||
#### mhchem
|
#### mhchem
|
||||||
|
|
||||||
|
|||||||
@@ -246,32 +246,37 @@ resources:
|
|||||||
|
|
||||||
在你的 [网站配置](../theme-documentation-basics#site-configuration) 中的 `[params.math]` 下面设置属性 `enable = true`,
|
在你的 [网站配置](../theme-documentation-basics#site-configuration) 中的 `[params.math]` 下面设置属性 `enable = true`,
|
||||||
并在文章的前置参数中设置属性 `math: true`来启用数学公式的自动渲染.
|
并在文章的前置参数中设置属性 `math: true`来启用数学公式的自动渲染.
|
||||||
|
**$\KaTeX$** 根据 **特定的分隔符** 来自动渲染公式.
|
||||||
|
|
||||||
{{< admonition tip >}}
|
{{< admonition tip >}}
|
||||||
有一份 [$\KaTeX$ 中支持的 $\TeX$ 函数](https://katex.org/docs/supported.html) 清单.
|
有一份 [$\KaTeX$ 中支持的 $\TeX$ 函数](https://katex.org/docs/supported.html) 清单.
|
||||||
{{< /admonition >}}
|
{{< /admonition >}}
|
||||||
|
|
||||||
#### 公式块
|
{{< admonition >}}
|
||||||
|
由于 Hugo 在渲染 Markdown 文档时会根据 `_`/`*`/`>>` 之类的语法生成 HTML 文档,
|
||||||
|
并且有些转义字符形式的文本内容 (如 `\(`/`\)`/`\[`/`\]`/`\\`) 会自动进行转义处理,
|
||||||
|
因此需要对这些地方进行额外的转义字符表达来实现自动渲染:
|
||||||
|
|
||||||
默认的公式块分割符是 `$$`/`$$` 和 `\\[`/`\\]`:
|
* `_` -> `\_`
|
||||||
|
* `*` -> `\*`
|
||||||
```markdown
|
* `>>` -> `\>>`
|
||||||
$$ c = \pm\sqrt{a^2 + b^2} $$
|
* `\(` -> `\\(`
|
||||||
|
* `\)` -> `\\)`
|
||||||
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
|
* `\[` -> `\\[`
|
||||||
```
|
* `\]` -> `\\]`
|
||||||
|
* `\\` -> `\\\\`
|
||||||
呈现的输出效果如下:
|
{{< /admonition >}}
|
||||||
|
|
||||||
$$ c = \pm\sqrt{a^2 + b^2} $$
|
|
||||||
|
|
||||||
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
|
|
||||||
|
|
||||||
#### 行内公式
|
#### 行内公式
|
||||||
|
|
||||||
默认的行内公式分割符是 `$`/`$` 和 `\\(`/`\\)`:
|
默认的行内公式分割符有:
|
||||||
|
|
||||||
```markdown
|
* `$ ... $`
|
||||||
|
* `\( ... \)` (转义的: `\\( ... \\)`)
|
||||||
|
|
||||||
|
例如:
|
||||||
|
|
||||||
|
```tex
|
||||||
$c = \pm\sqrt{a^2 + b^2}$ 和 \\(f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi\\)
|
$c = \pm\sqrt{a^2 + b^2}$ 和 \\(f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi\\)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -279,8 +284,92 @@ $ c = \pm\sqrt{a^2 + b^2} $ 和 \\( f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^
|
|||||||
|
|
||||||
$c = \pm\sqrt{a^2 + b^2}$ 和 \\(f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi\\)
|
$c = \pm\sqrt{a^2 + b^2}$ 和 \\(f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi\\)
|
||||||
|
|
||||||
|
#### 公式块
|
||||||
|
|
||||||
|
默认的公式块分割符有:
|
||||||
|
|
||||||
|
* `$$ ... $$`
|
||||||
|
* `\[ ... \]` (转义的: `\\[ ... \\]`)
|
||||||
|
* `\begin{equation} ... \end{equation}` (不编号的: `\begin{equation*} ... \end{equation*}`)
|
||||||
|
* `\begin{align} ... \end{align}` (不编号的: `\begin{align*} ... \end{align*}`)
|
||||||
|
* `\begin{alignat} ... \end{alignat}` (不编号的: `\begin{alignat*} ... \end{alignat*}`)
|
||||||
|
* `\begin{gather} ... \end{gather}` (不编号的: `\begin{gather*} ... \end{gather*}`)
|
||||||
|
* `\begin{CD} ... \end{CD}`
|
||||||
|
|
||||||
|
例如:
|
||||||
|
|
||||||
|
```tex
|
||||||
|
$$ c = \pm\sqrt{a^2 + b^2} $$
|
||||||
|
|
||||||
|
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
|
||||||
|
|
||||||
|
\begin{equation*}
|
||||||
|
\rho \frac{\mathrm{D} \mathbf{v}}{\mathrm{D} t}=\nabla \cdot \mathbb{P}+\rho \mathbf{f}
|
||||||
|
\end{equation*}
|
||||||
|
|
||||||
|
\begin{equation}
|
||||||
|
\mathbf{E}=\sum_{i} \mathbf{E}\_{i}=\mathbf{E}\_{1}+\mathbf{E}\_{2}+\mathbf{E}_{3}+\cdots
|
||||||
|
\end{equation}
|
||||||
|
|
||||||
|
\begin{align}
|
||||||
|
a&=b+c \\\\
|
||||||
|
d+e&=f
|
||||||
|
\end{align}
|
||||||
|
|
||||||
|
\begin{alignat}{2}
|
||||||
|
10&x+&3&y = 2 \\\\
|
||||||
|
3&x+&13&y = 4
|
||||||
|
\end{alignat}
|
||||||
|
|
||||||
|
\begin{gather}
|
||||||
|
a=b \\\\
|
||||||
|
e=b+c
|
||||||
|
\end{gather}
|
||||||
|
|
||||||
|
\begin{CD}
|
||||||
|
A @>a\>> B \\\\
|
||||||
|
@VbVV @AAcA \\\\
|
||||||
|
C @= D
|
||||||
|
\end{CD}
|
||||||
|
```
|
||||||
|
|
||||||
|
呈现的输出效果如下:
|
||||||
|
|
||||||
|
$$ c = \pm\sqrt{a^2 + b^2} $$
|
||||||
|
|
||||||
|
\\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \\]
|
||||||
|
|
||||||
|
\begin{equation*}
|
||||||
|
\rho \frac{\mathrm{D} \mathbf{v}}{\mathrm{D} t}=\nabla \cdot \mathbb{P}+\rho \mathbf{f}
|
||||||
|
\end{equation*}
|
||||||
|
|
||||||
|
\begin{equation}
|
||||||
|
\mathbf{E}=\sum_{i} \mathbf{E}\_{i}=\mathbf{E}\_{1}+\mathbf{E}\_{2}+\mathbf{E}_{3}+\cdots
|
||||||
|
\end{equation}
|
||||||
|
|
||||||
|
\begin{align}
|
||||||
|
a&=b+c \\\\
|
||||||
|
d+e&=f
|
||||||
|
\end{align}
|
||||||
|
|
||||||
|
\begin{alignat}{2}
|
||||||
|
10&x+&3&y = 2 \\\\
|
||||||
|
3&x+&13&y = 4
|
||||||
|
\end{alignat}
|
||||||
|
|
||||||
|
\begin{gather}
|
||||||
|
a=b \\\\
|
||||||
|
e=b+c
|
||||||
|
\end{gather}
|
||||||
|
|
||||||
|
\begin{CD}
|
||||||
|
A @>a\>> B \\\\
|
||||||
|
@VbVV @AAcA \\\\
|
||||||
|
C @= D
|
||||||
|
\end{CD}
|
||||||
|
|
||||||
{{< admonition tip >}}
|
{{< admonition tip >}}
|
||||||
你可以在 [网站配置](../theme-documentation-basics#site-configuration) 中自定义公式块和行内公式的分割符.
|
你可以在 [网站配置](../theme-documentation-basics#site-configuration) 中自定义行内公式和公式块的分割符.
|
||||||
{{< /admonition >}}
|
{{< /admonition >}}
|
||||||
|
|
||||||
#### Copy-tex
|
#### Copy-tex
|
||||||
@@ -291,7 +380,7 @@ $ c = \pm\sqrt{a^2 + b^2} $ 和 \\( f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^
|
|||||||
|
|
||||||
在你的 [网站配置](../theme-documentation-basics#site-configuration) 中的 `[params.math]` 下面设置属性 `copyTex = true` 来启用 Copy-tex.
|
在你的 [网站配置](../theme-documentation-basics#site-configuration) 中的 `[params.math]` 下面设置属性 `copyTex = true` 来启用 Copy-tex.
|
||||||
|
|
||||||
选择并复制上一节中渲染的公式, 可以发现复制的内容为 LaTeX 源代码.
|
选择并复制上一节中渲染的公式, 可以发现复制的内容为 $\LaTeX$ 源代码.
|
||||||
|
|
||||||
#### mhchem
|
#### mhchem
|
||||||
|
|
||||||
|
|||||||
@@ -106,14 +106,22 @@
|
|||||||
{{- $source := $cdn.katexMhchemJS | default "lib/katex/mhchem.min.js" -}}
|
{{- $source := $cdn.katexMhchemJS | default "lib/katex/mhchem.min.js" -}}
|
||||||
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- $delimiters := slice (dict "left" "$$" "right" "$$" "display" true) (dict "left" "\\[" "right" "\\]" "display" true) -}}
|
{{- $delimiters := slice (dict "left" "$" "right" "$" "display" false) (dict "left" "\\(" "right" "\\)" "display" false) -}}
|
||||||
{{- if and $math.blockLeftDelimiter $math.blockRightDelimiter -}}
|
|
||||||
{{- $delimiters = $delimiters | append (dict "left" $math.blockLeftDelimiter "right" $math.blockRightDelimiter "display" true) -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- $delimiters = $delimiters | append (dict "left" "$" "right" "$" "display" false) (dict "left" "\\(" "right" "\\)" "display" false) -}}
|
|
||||||
{{- if and $math.inlineLeftDelimiter $math.inlineRightDelimiter -}}
|
{{- if and $math.inlineLeftDelimiter $math.inlineRightDelimiter -}}
|
||||||
{{- $delimiters = $delimiters | append (dict "left" $math.inlineRightDelimiter "right" $math.inlineRightDelimiter "display" false) -}}
|
{{- $delimiters = $delimiters | append (dict "left" $math.inlineRightDelimiter "right" $math.inlineRightDelimiter "display" false) -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
{{- $delimiters = $delimiters | append (dict "left" "$$" "right" "$$" "display" true) (dict "left" "\\[" "right" "\\]" "display" true) -}}
|
||||||
|
{{- $delimiters = $delimiters | append (dict "left" "\\begin{equation}" "right" "\\end{equation}" "display" true) -}}
|
||||||
|
{{- $delimiters = $delimiters | append (dict "left" "\\begin{equation*}" "right" "\\end{equation*}" "display" true) -}}
|
||||||
|
{{- $delimiters = $delimiters | append (dict "left" "\\begin{align}" "right" "\\end{align}" "display" true) -}}
|
||||||
|
{{- $delimiters = $delimiters | append (dict "left" "\\begin{align*}" "right" "\\end{align*}" "display" true) -}}
|
||||||
|
{{- $delimiters = $delimiters | append (dict "left" "\\begin{alignat}" "right" "\\end{alignat}" "display" true) -}}
|
||||||
|
{{- $delimiters = $delimiters | append (dict "left" "\\begin{alignat*}" "right" "\\end{alignat*}" "display" true) -}}
|
||||||
|
{{- $delimiters = $delimiters | append (dict "left" "\\begin{gather}" "right" "\\end{gather}" "display" true) -}}
|
||||||
|
{{- $delimiters = $delimiters | append (dict "left" "\\begin{CD}" "right" "\\end{CD}" "display" true) -}}
|
||||||
|
{{- if and $math.blockLeftDelimiter $math.blockRightDelimiter -}}
|
||||||
|
{{- $delimiters = $delimiters | append (dict "left" $math.blockLeftDelimiter "right" $math.blockRightDelimiter "display" true) -}}
|
||||||
|
{{- end -}}
|
||||||
{{- $config = dict "strict" false "delimiters" $delimiters | dict "math" | merge $config -}}
|
{{- $config = dict "strict" false "delimiters" $delimiters | dict "math" | merge $config -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user