This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from pkra/wilbowma
Basic support for MathJax custom script types
- Loading branch information
Showing
2 changed files
with
67 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const tape = require('tape'); | ||
const mjpage = require('../lib/main.js').mjpage; | ||
const jsdom = require('jsdom').jsdom; | ||
|
||
tape('Custom script types are processed correctly', function(t) { | ||
t.plan(4); | ||
const inlineInput = '<script type="math/tex"> e^{i\\pi} = -1</script>'; | ||
mjpage(inlineInput, { | ||
format: ['TeX'] | ||
}, { | ||
svg: true | ||
}, function(output) { | ||
const window = jsdom(output).defaultView; | ||
const expected = window.document.querySelector('.mjpage'); | ||
t.ok(expected, '"math/tex" treated as inline'); | ||
}); | ||
|
||
const displayInput = '<script type="math/tex; mode=display"> e^{i\\pi} = -1</script>'; | ||
mjpage(displayInput, { | ||
format: ['TeX'] | ||
}, { | ||
svg: true | ||
}, function(output) { | ||
const window = jsdom(output).defaultView; | ||
const expected = window.document.querySelector('.mjpage__block'); | ||
t.ok(expected, '"math/tex; mode=display" treated as block'); | ||
}); | ||
|
||
const asciiInput = '<script type="math/asciimath">alpha</script>'; | ||
mjpage(displayInput, { | ||
format: ['TeX'] | ||
}, { | ||
svg: true | ||
}, function(output) { | ||
const window = jsdom(output).defaultView; | ||
const expected = window.document.querySelector('.mjpage'); | ||
t.ok(expected, '"math/asciimath" treated as asciimath'); | ||
}); | ||
|
||
const crazyCaseInput = '<script type="math/blarg"> e^{i\\pi} = -1</script>'; | ||
mjpage(crazyCaseInput, { | ||
format: ['TeX'] | ||
}, { | ||
svg: true | ||
}, function(output) { | ||
const window = jsdom(output).defaultView; | ||
const expected = window.document.querySelector('.mjpage'); | ||
t.notOk(expected, 'Other scripts are ignored'); | ||
}); | ||
|
||
}); |