mathjax-img
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [3.2.0](https://github.com/pkra/mathjax-img/compare/v3.1.0...v3.2.0) (2022-06-28) | ||
### Features | ||
* support optional alt text ([05c880a](https://github.com/pkra/mathjax-img/commit/05c880a6883d930e7d15d04744c4e25899ad22b1)), closes [#2](https://github.com/pkra/mathjax-img/issues/2) | ||
## [3.1.0](https://github.com/pkra/mathjax-img/compare/v3.0.0...v3.1.0) (2021-05-07) | ||
@@ -7,0 +14,0 @@ |
12
img.js
/************************************************************* | ||
* | ||
* img.js | ||
* | ||
* Implements TeX macro for embedding images | ||
* | ||
* Usage: | ||
* | ||
* \img{URL}{vertical alignment}{width}{height} | ||
* | ||
* --------------------------------------------------------------------- | ||
* | ||
* Copyright (c) 2020 The MathJax Consortium | ||
@@ -72,2 +62,3 @@ * | ||
} | ||
def.alt = parser.GetBrackets(name, ''); | ||
def.src = parser.GetArgument(name); | ||
@@ -77,2 +68,3 @@ if (!def.valign) delete def.valign; | ||
if (!def.height) delete def.height; | ||
if (!def.alt) delete def.alt; | ||
parser.Push(parser.create('token', 'mglyph', def)); | ||
@@ -79,0 +71,0 @@ }, |
{ | ||
"name": "mathjax-img", | ||
"main": "./img.js", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "img extension for MathJax's TeX input", | ||
@@ -26,10 +26,11 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/core": "^7.14.0", | ||
"@babel/preset-env": "^7.14.1", | ||
"babel-loader": "^8.2.2", | ||
"mathjax-full": "^3.1.4", | ||
"standard-version": "^9.3.0", | ||
"terser-webpack-plugin": "^5.1.1", | ||
"webpack": "^5.36.2", | ||
"webpack-cli": "^4.7.0" | ||
"@babel/core": "7.16.12", | ||
"@babel/preset-env": "7.16.11", | ||
"babel-loader": "8.2.3", | ||
"mathjax-full": "^3.2.0", | ||
"standard-version": "9.3.2", | ||
"terser-webpack-plugin": "5.3.0", | ||
"typescript": "4.5.5", | ||
"webpack": "5.67.0", | ||
"webpack-cli": "^4.9.1" | ||
}, | ||
@@ -39,4 +40,4 @@ "scripts": { | ||
"release": "standard-version", | ||
"test": "echo 'No tests yet'" | ||
"test": "node test/base.js" | ||
} | ||
} |
# mathjax-img | ||
MathJax TeX extension to embed images in math. | ||
MathJax TeX extension to embed images. | ||
## MathJax Extension: `img.js`, leveraging mglyph in TeX input | ||
This extension implements a TeX macro `\img` for embedding images in mathematical formula. It leverages the standard MathML mglyph tag which is designed for this purpose. | ||
This extension implements a TeX macro `\img` for embedding images in mathematical formula. | ||
## Usage: | ||
\img[valign=<vertical alignment>,width=<width>,height=<height>]{URL} | ||
\img[valign=<vertical alignment>,width=<width>,height=<height>][<alttext>]{URL} | ||
or | ||
\img[<vertical alignment>][<width>][<height>]{URL} | ||
\img[<vertical alignment>][<width>][<height>][<alttext>]{URL} | ||
This adds an `\img` macro for inserting images into a MathJax expression. It takes 4 arguments: the URL for the image, the vertical alignment value, the width, and the height of the image. Any of the final three can be blank in order to use the default. | ||
This adds an `\img` macro for inserting images into a MathJax expression. It takes 5 arguments: the URL for the image and, optionally, the vertical alignment value, the width, the height, and the alttext. Any of the final four can be blank in order to use the default. | ||
With no vertical-align value, the image will sit on the baseline. With no width or height, the image will be its natural size. With one of the width or height specified, the image will be scaled to match that dimension while keeping the aspect ratio the same. If both are given, then image will be scaled to match both dimensions, without regard to the original aspect ratio. | ||
With no vertical-align value, the image will sit on the baseline. With no width or height, the image will be its natural size. With one of the width or height specified, the image will be scaled to match that dimension while keeping the aspect ratio the same. If both are given, then image will be scaled to match both dimensions, without regard to the original aspect ratio. The alttext will be used to provide a textual alternative in the rendering. | ||
## Using NodeJS | ||
### MathJax v3 (mathjax-img v2) | ||
Install `mathjax-full` and `mathjax-img` and follow the instructions for NodeJS, e.g., | ||
const { TeX } = require('mathjax/js/input/tex.js'); | ||
const img = require('mathjax-img').configuration; | ||
const img = require('mathjax-img').configuration; // OR import { configuration as img } from 'mathjax-img'; | ||
const tex = new TeX({ | ||
packages: [img.name] | ||
packages: [img.name] | ||
}); | ||
### MathJax v2 (mathjax-img v1 only) | ||
Install mathjax-node and mathjax-img and follow the instructions for mathjax-node, e.g., | ||
const mathjax = require('mathjax-node'); | ||
mathjax.config({ | ||
paths: { | ||
img: path.dirname(require.resolve('mathjax-img')), | ||
}, | ||
extensions: | ||
'[img]/img' | ||
}); | ||
## Using a browser | ||
### MathJax v3 | ||
For client-side use, you need load `img.min.js`. | ||
@@ -57,26 +38,11 @@ | ||
MathJax = { | ||
loader: { | ||
load: ['[img]/img.min.js'], | ||
paths: {img: 'https://cdn.jsdelivr.net/npm/mathjax-img@3/'} | ||
}, | ||
tex: { | ||
packages: {'[+]': ['img']} | ||
} | ||
loader: { | ||
load: ['[img]/img.min.js'], | ||
paths: {img: 'https://cdn.jsdelivr.net/npm/mathjax-img@3'} | ||
}, | ||
tex: { | ||
packages: {'[+]': ['img']} | ||
} | ||
}; | ||
### MathJax v2 | ||
To use a CDN copy, you need MathJax v2.4 (or higher) and configure a custom path `[img]` as described in the [MathJax documentation](http://docs.mathjax.org/en/latest/options/ThirdParty.html#custom-extension-path-configuration). | ||
Then add the extension to your configuration using the custom path. For example, | ||
<script type="text/x-mathjax-config> | ||
MathJax.Ajax.config.path["img"] = "https://cdn.rawgit.com/pkra/mathjax-img/1.0.0/"; | ||
MathJax.Hub.Config({ | ||
extensions: ["tex2jax.js","[img]/img.js"], | ||
jax: ["input/TeX","output/HTML-CSS"], | ||
tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]}, | ||
}); | ||
</script> | ||
## References | ||
@@ -83,0 +49,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
28755
12
126
0
9
53
1