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
8 changed files
with
533 additions
and
286 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
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,38 @@ | ||
'use strict'; | ||
|
||
/* Dependencies. */ | ||
var all = require('../all'); | ||
var one = require('../one'); | ||
var has = require('has'); | ||
|
||
/* Expose. */ | ||
module.exports = math; | ||
|
||
var defaultMacros = { | ||
inlineMath: function inlineMath(content) { | ||
return '$' + content + '$'; | ||
}, | ||
inlineMathDouble: function inlineMathDouble(content) { | ||
return '$$' + content + '$$'; | ||
}, | ||
math: function math(content) { | ||
return '\\[ ' + content + ' \\]\n\n'; | ||
} | ||
|
||
/* Stringify a Figure `node`. */ | ||
};function math(ctx, node, index, parent) { | ||
var type = 'math'; | ||
if (node.type === 'inlineMath') { | ||
try { | ||
var classes = node.data.hProperties.className.split(' '); | ||
type = classes.includes('inlineMathDouble') ? 'inlineMathDouble' : 'inlineMath'; | ||
} catch (e) { | ||
console.error(e, 'This rebber math plugin is only compatible with remark-math.'); | ||
} | ||
} | ||
|
||
var macro = has(ctx, 'math') && has(ctx.math, type) && ctx.math[type] || has(defaultMacros, type) && defaultMacros[type]; | ||
|
||
var content = all(ctx, node) || node.value || ''; | ||
return macro(content.trim()); | ||
} |
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,32 @@ | ||
/* Dependencies. */ | ||
const all = require('../all') | ||
const one = require('../one') | ||
const has = require('has') | ||
|
||
/* Expose. */ | ||
module.exports = math | ||
|
||
const defaultMacros = { | ||
inlineMath: (content) => `$${content}$`, | ||
inlineMathDouble: (content) => `$$${content}$$`, | ||
math: (content) => `\\[ ${content} \\]\n\n`, | ||
} | ||
|
||
/* Stringify a Figure `node`. */ | ||
function math (ctx, node, index, parent) { | ||
let type = 'math' | ||
if (node.type === 'inlineMath') { | ||
try { | ||
const classes = node.data.hProperties.className.split(' ') | ||
type = classes.includes('inlineMathDouble') ? 'inlineMathDouble' : 'inlineMath' | ||
} catch (e) { | ||
console.error(e, 'This rebber math plugin is only compatible with remark-math.') | ||
} | ||
} | ||
|
||
const macro = (has(ctx, 'math') && has(ctx.math, type) && ctx.math[type]) || | ||
(has(defaultMacros, type) && defaultMacros[type]) | ||
|
||
const content = all(ctx, node) || node.value || '' | ||
return macro(content.trim()) | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.