mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 15:42:59 +00:00 
			
		
		
		
	Merge pull request #2154 from spelufo/katex-displaymode
Revert katex plugin to using `$$`. Use multiline for display mode.
This commit is contained in:
		| @@ -22,30 +22,42 @@ These examples are taken from http://khan.github.io/KaTeX/ | ||||
|  | ||||
| !! Example 1 | ||||
|  | ||||
| To render in display mode use `$$$`: | ||||
| If the text between `$$` contains newlines it will rendered in display mode: | ||||
|  | ||||
| ``` | ||||
| $$$ f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi $$$ | ||||
| $$ | ||||
| f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi | ||||
| $$ | ||||
| ``` | ||||
|  | ||||
| $$$ f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi $$$ | ||||
| $$ | ||||
| f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi | ||||
| $$ | ||||
|  | ||||
| !! Example 2 | ||||
|  | ||||
| ``` | ||||
| $$$ \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } } $$$ | ||||
| $$ | ||||
| \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } } | ||||
| $$ | ||||
| ``` | ||||
|  | ||||
| $$$ \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } } $$$ | ||||
| $$ | ||||
| \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } } | ||||
| $$ | ||||
|  | ||||
|  | ||||
| !! Example 3 | ||||
|  | ||||
| ``` | ||||
| $$$ 1 +  \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots = \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for }\lvert q\rvert<1. $$$ | ||||
| $$ | ||||
| 1 +  \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots = \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for }\lvert q\rvert<1. | ||||
| $$ | ||||
| ``` | ||||
|  | ||||
| $$$ 1 +  \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots = \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for }\lvert q\rvert<1. $$$ | ||||
| $$ | ||||
| 1 +  \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots = \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for }\lvert q\rvert<1. | ||||
| $$ | ||||
|  | ||||
| !! Widget Example | ||||
|  | ||||
|   | ||||
| @@ -29,13 +29,13 @@ exports.types = {inline: true}; | ||||
| exports.init = function(parser) { | ||||
| 	this.parser = parser; | ||||
| 	// Regexp to match | ||||
| 	this.matchRegExp = /\$\$\$?(?!\$)/mg; | ||||
| 	this.matchRegExp = /\$\$(?!\$)/mg; | ||||
| }; | ||||
|  | ||||
| exports.parse = function() { | ||||
| 	// Move past the match | ||||
| 	this.parser.pos = this.matchRegExp.lastIndex; | ||||
| 	var reEnd = /\$\$\$?/mg; | ||||
| 	var reEnd = /\$\$/mg; | ||||
| 	// Look for the end marker | ||||
| 	reEnd.lastIndex = this.parser.pos; | ||||
| 	var match = reEnd.exec(this.parser.source), | ||||
| @@ -44,7 +44,7 @@ exports.parse = function() { | ||||
| 	// Process the text | ||||
| 	if(match) { | ||||
| 		text = this.parser.source.substring(this.parser.pos,match.index); | ||||
| 		displayMode = match.indexOf('$$$') != -1; | ||||
| 		displayMode = text.indexOf('\n') != -1; | ||||
| 		this.parser.pos = match.index + match[0].length; | ||||
| 	} else { | ||||
| 		text = this.parser.source.substr(this.parser.pos); | ||||
|   | ||||
| @@ -6,7 +6,7 @@ The usual way to include ~LaTeX is to use `$$`. For example: | ||||
| $$\displaystyle f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi$$ | ||||
| ``` | ||||
|  | ||||
| To make math render in display mode, use `$$$` instead of `$$`. | ||||
| Single line equations will render in inline mode. If there are newlines between the `$$` delimiters, the equations will be rendered in display mode. | ||||
|  | ||||
| The underlying widget can also be used directly, giving more flexibility: | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jeremy Ruston
					Jeremy Ruston