-
Notifications
You must be signed in to change notification settings - Fork 737
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
5 changed files
with
110 additions
and
0 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 @@ | ||
(sin(2x) + e^x) / 2 |
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 @@ | ||
export const id = 'mathjs'; | ||
export const displayName = 'Math.js'; | ||
export const mimeTypes = ['text/mathjs']; | ||
export const fileExtension = 'mathjs'; |
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,42 @@ | ||
import pkg from 'mathjs/package.json'; | ||
|
||
import defaultParserInterface from '../utils/defaultParserInterface' | ||
|
||
const ID = 'mathjs' | ||
|
||
export default { | ||
...defaultParserInterface, | ||
|
||
id: ID, | ||
displayName: ID, | ||
version: pkg.version, | ||
homepage: 'https://mathjs.org/', | ||
locationProps: new Set(['span']), | ||
|
||
defaultParserID: 'mathjs', | ||
|
||
async loadParser(callback) { | ||
require(['mathjs'], callback); | ||
}, | ||
|
||
parse(parser, code) { | ||
try { | ||
return parser.parse(code) | ||
} catch (message) { | ||
// AST Explorer expects the thrown error to be an object, not a string. | ||
throw new SyntaxError(message); | ||
} | ||
}, | ||
|
||
getNodeName(node) { | ||
return node.type | ||
}, | ||
|
||
// TODO once this feature is added to mathjs | ||
// nodeToRange(node) { | ||
// }, | ||
|
||
opensByDefault(node) { | ||
return node.type === 'BlockNode' | ||
}, | ||
} |
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