Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ When enabled the extension will make a GET request every second to:

The following `mathjax` delimiters are supported:

- inline math: `\(math\)` and `$math$`
- display math: `\[math\]` and `$$math$$`
- inline math: `\(math\)`, `$math$`, and ``$`math`$``
- display math: `\[math\]`, `$$math$$`, and math code blocks (```` ```math ````)

The following rules apply to your content when `mathjax` is enabled:

Expand Down
1 change: 1 addition & 0 deletions background/mathjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ md.mathjax = () => {
/\\\[[^`]*?\\\]/,
/\\begin\{.*?\}[^`]*?\\end\{.*?\}/,
/\$[^`\n]*?\$/,
/\$`[^`\n]*?`\$/,
]
.map((regex) => `(?:${regex.source})`).join('|'), 'gi')

Expand Down
9 changes: 9 additions & 0 deletions content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ function mount () {
dom.push(m('script', {
src: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js'
}))
dom.push(m('script', {type: 'text/javascript'}, `
;(() => {
var mathblocks = document.querySelectorAll('code.language-math')
mathblocks.forEach(mathblock => {
mathblock.parentNode.replaceWith("$$" + mathblock.textContent + "$$")
})
})()
`))
}
if (state.content.mermaid) {
dom.push(m('script', {
Expand Down Expand Up @@ -336,6 +344,7 @@ var mathjax = `
inlineMath: [
['$', '$'],
['\\\\(', '\\\\)'],
['$\`', '\`$'],
],
displayMath: [
['$$', '$$'],
Expand Down