-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
420 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
coverage/ | ||
node_modules/ | ||
.DS_Store | ||
*.d.ts | ||
*.log | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["*.js"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,39 @@ | ||
/** | ||
* @typedef {import('hast').Root} Root | ||
* @typedef {import('hast').Element} Element | ||
* @typedef {import('./lib/create-plugin').MathNotation} MathNotation | ||
* @typedef {import('./lib/create-plugin').BrowserOptions} Options | ||
*/ | ||
|
||
import {createPlugin} from './lib/create-plugin.js' | ||
|
||
const rehypeMathJaxBrowser = createPlugin( | ||
'rehypeMathJaxBrowser', | ||
renderBrowser, | ||
false, | ||
true | ||
) | ||
export default rehypeMathJaxBrowser | ||
const rehypeMathJaxBrowser = | ||
/** @type {import('unified').Plugin<[Options?]|void[], Root>} */ ( | ||
createPlugin( | ||
// To do next major: Make `options` match the format of MathJax options | ||
// `{tex: ...}` | ||
(_, options) => { | ||
/** @type {MathNotation} */ | ||
let display = ['\\[', '\\]'] | ||
/** @type {MathNotation} */ | ||
let inline = ['\\(', '\\)'] | ||
|
||
// To do next major: Make `options` match the format of MathJax options | ||
// `{tex: ...}` | ||
function renderBrowser(options) { | ||
const settings = options || {} | ||
const display = settings.displayMath || ['\\[', '\\]'] | ||
const inline = settings.inlineMath || ['\\(', '\\)'] | ||
if ('displayMath' in options && options.displayMath) { | ||
display = options.displayMath | ||
} | ||
|
||
return {render} | ||
if ('inlineMath' in options && options.inlineMath) { | ||
inline = options.inlineMath | ||
} | ||
|
||
function render(node, renderOptions) { | ||
const delimiters = renderOptions.display ? display : inline | ||
node.children.unshift({type: 'text', value: delimiters[0]}) | ||
node.children.push({type: 'text', value: delimiters[1]}) | ||
} | ||
} | ||
return { | ||
render(node, options) { | ||
const delimiters = options.display ? display : inline | ||
node.children.unshift({type: 'text', value: delimiters[0]}) | ||
node.children.push({type: 'text', value: delimiters[1]}) | ||
} | ||
} | ||
} | ||
) | ||
) | ||
export default rehypeMathJaxBrowser |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import {createInput} from './lib/create-input.js' | ||
/** | ||
* @typedef {import('hast').Root} Root | ||
* @typedef {import('./lib/create-plugin').CHtmlOptions} Options | ||
*/ | ||
|
||
import {createOutputChtml} from './lib/create-output-chtml.js' | ||
import {createRenderer} from './lib/create-renderer.js' | ||
import {createPlugin} from './lib/create-plugin.js' | ||
|
||
const rehypeMathJaxCHtml = createPlugin('rehypeMathJaxCHtml', renderCHtml, true) | ||
const rehypeMathJaxCHtml = | ||
/** @type {import('unified').Plugin<[Options?]|void[], Root>} */ | ||
( | ||
createPlugin( | ||
(inputOptions, outputOptions) => | ||
createRenderer(inputOptions, createOutputChtml(outputOptions)), | ||
true | ||
) | ||
) | ||
|
||
export default rehypeMathJaxCHtml | ||
|
||
function renderCHtml(inputOptions, outputOptions) { | ||
return createRenderer( | ||
createInput(inputOptions), | ||
createOutputChtml(outputOptions) | ||
) | ||
} |
Oops, something went wrong.