Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mathjax-angular

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathjax-angular - npm Package Compare versions

Comparing version 0.0.1 to 0.5.0

directive/index.d.ts

175

bundles/mathjax-angular.umd.js

@@ -29,54 +29,144 @@ (function (global, factory) {

var MathjaxLibService = /** @class */ (function () {
function MathjaxLibService() {
var isMathjax = /(?:\$|\\\(|\\\[|\\begin\{.*?})/;
//export const isMathJax = /(?:(?:^|[-+_*/])(?:\s*-?\d+(\.\d+)?(?:[eE][+-]?\d+)?\s*))+$/;
var mathjax_url = 'https://cdn.jsdelivr.net/npm/mathjax@3.0.0/es5/startup.js';
var MathjaxDefaultConfig = {
loader: {
load: ['output/svg', '[tex]/require'],
},
tex: {
inlineMath: [['$', '$']],
displayMath: [['$$', '$$']],
packages: ['base', 'require'],
},
};
//
var RootMathjaxConfig = /** @class */ (function () {
function RootMathjaxConfig() {
}
return MathjaxLibService;
return RootMathjaxConfig;
}());
MathjaxLibService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxLibService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
MathjaxLibService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxLibService, providedIn: 'root' });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxLibService, decorators: [{
type: i0.Injectable,
args: [{
providedIn: 'root'
}]
}], ctorParameters: function () { return []; } });
var MathjaxLibComponent = /** @class */ (function () {
function MathjaxLibComponent() {
var MathjaxDirective = /** @class */ (function () {
//
function MathjaxDirective(el) {
this.el = el;
if (this.mathJaxExpressions) {
this.mathJaxExpressions =
'string' === typeof this.mathJaxExpressions
? this.mathJaxExpressions
: this.mathJaxExpressions.latex ||
this.mathJaxExpressions.mathml;
}
else {
this.element = el.nativeElement;
}
this.element = el.nativeElement;
}
MathjaxLibComponent.prototype.ngOnInit = function () {
Object.defineProperty(MathjaxDirective.prototype, "mathjax", {
//
set: function (val) {
this.mathJaxExpressions = val;
},
enumerable: false,
configurable: true
});
MathjaxDirective.prototype.ngOnChanges = function (changes) {
var _this = this;
var _a;
var expressions = changes.mathjax;
if (!expressions ||
expressions.currentValue === expressions.previousValue) {
return;
}
//
if ((_a = (expressions.currentValue + '')) === null || _a === void 0 ? void 0 : _a.match(isMathjax)) {
var filteredVal_1 = this.fixMathjaxBugs(expressions.currentValue + '');
this.typeset(function () {
_this.element.innerHTML = "<div>" + filteredVal_1 + "</div>";
});
}
else {
this.element.innerHTML = expressions.currentValue;
}
};
return MathjaxLibComponent;
MathjaxDirective.prototype.fixMathjaxBugs = function (jax) {
return (jax
//line break error
.replace(/<br \/>/gi, '<br/> ')
//automatic breakline
.replace(/[$]([\s\S]+?)[$]/gi, function (m, p, o, s) {
//return /s/gi.test(p)
return p.includes('\\\\') && !p.includes('\\begin')
? "$\\begin{align*}" + p + "\\end{align*}$"
: "$" + p + "$";
}));
};
MathjaxDirective.prototype.typeset = function (code) {
if (MathJax === null || MathJax === void 0 ? void 0 : MathJax.startup) {
MathJax.startup.promise = MathJax.startup.promise
.then(function () {
code();
return MathJax.typesetPromise ? MathJax.typesetPromise() : null;
})
.catch(function (err) { return console.error('MathJax Typeset failed: ' + err.message); });
return MathJax.startup.promise;
}
else {
code();
}
};
return MathjaxDirective;
}());
MathjaxLibComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxLibComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
MathjaxLibComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.1", type: MathjaxLibComponent, selector: "lib-mathjax-lib", ngImport: i0__namespace, template: "\n <p>\n mathjax-lib works!\n </p>\n ", isInline: true });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxLibComponent, decorators: [{
type: i0.Component,
MathjaxDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxDirective, deps: [{ token: i0__namespace.ElementRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
MathjaxDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.1", type: MathjaxDirective, selector: "mathjax,[mathjax]", inputs: { mathjax: "mathjax" }, usesOnChanges: true, ngImport: i0__namespace });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxDirective, decorators: [{
type: i0.Directive,
args: [{
selector: 'lib-mathjax-lib',
template: "\n <p>\n mathjax-lib works!\n </p>\n ",
styles: []
selector: 'mathjax,[mathjax]',
}]
}], ctorParameters: function () { return []; } });
}], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }]; }, propDecorators: { mathjax: [{
type: i0.Input,
args: ['mathjax']
}] } });
var MathjaxLibModule = /** @class */ (function () {
function MathjaxLibModule() {
var MathjaxModule = /** @class */ (function () {
function MathjaxModule(moduleConfig) {
var _a, _b;
//
//
var config = document.createElement('script');
var providConfig = Object.assign(Object.assign({}, MathjaxDefaultConfig), ((_a = moduleConfig === null || moduleConfig === void 0 ? void 0 : moduleConfig.config) !== null && _a !== void 0 ? _a : {}));
config.text = "MathJax = " + JSON.stringify(providConfig);
//
//
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = (_b = moduleConfig === null || moduleConfig === void 0 ? void 0 : moduleConfig.src) !== null && _b !== void 0 ? _b : mathjax_url;
script.async = true;
//
}
return MathjaxLibModule;
MathjaxModule.forRoot = function (config) {
return {
ngModule: MathjaxModule,
providers: [{ provide: RootMathjaxConfig, useValue: config !== null && config !== void 0 ? config : {} }],
};
};
MathjaxModule.forChild = function () {
return {
ngModule: MathjaxModule,
};
};
return MathjaxModule;
}());
MathjaxLibModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxLibModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
MathjaxLibModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxLibModule, declarations: [MathjaxLibComponent], exports: [MathjaxLibComponent] });
MathjaxLibModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxLibModule, imports: [[]] });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxLibModule, decorators: [{
MathjaxModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxModule, deps: [{ token: RootMathjaxConfig }], target: i0__namespace.ɵɵFactoryTarget.NgModule });
MathjaxModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxModule, declarations: [MathjaxDirective], exports: [MathjaxDirective] });
MathjaxModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxModule });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0__namespace, type: MathjaxModule, decorators: [{
type: i0.NgModule,
args: [{
declarations: [
MathjaxLibComponent
],
imports: [],
exports: [
MathjaxLibComponent
]
declarations: [MathjaxDirective],
exports: [MathjaxDirective],
}]
}] });
}], ctorParameters: function () { return [{ type: RootMathjaxConfig }]; } });

@@ -91,5 +181,8 @@ /*

exports.MathjaxLibComponent = MathjaxLibComponent;
exports.MathjaxLibModule = MathjaxLibModule;
exports.MathjaxLibService = MathjaxLibService;
exports.MathjaxDefaultConfig = MathjaxDefaultConfig;
exports.MathjaxDirective = MathjaxDirective;
exports.MathjaxModule = MathjaxModule;
exports.RootMathjaxConfig = RootMathjaxConfig;
exports.isMathjax = isMathjax;
exports.mathjax_url = mathjax_url;

@@ -96,0 +189,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

/*
* Public API Surface of mathjax-lib
*/
export * from './lib/mathjax-lib.service';
export * from './lib/mathjax-lib.component';
export * from './lib/mathjax-lib.module';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL21hdGhqYXgtbGliL3NyYy9wdWJsaWMtYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYywyQkFBMkIsQ0FBQztBQUMxQyxjQUFjLDZCQUE2QixDQUFDO0FBQzVDLGNBQWMsMEJBQTBCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxuICogUHVibGljIEFQSSBTdXJmYWNlIG9mIG1hdGhqYXgtbGliXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9saWIvbWF0aGpheC1saWIuc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9tYXRoamF4LWxpYi5jb21wb25lbnQnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvbWF0aGpheC1saWIubW9kdWxlJztcbiJdfQ==
export * from './directive';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL21hdGhqYXgtbGliL3NyYy9wdWJsaWMtYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxhQUFhLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxuICogUHVibGljIEFQSSBTdXJmYWNlIG9mIG1hdGhqYXgtbGliXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9kaXJlY3RpdmUnO1xuIl19
import * as i0 from '@angular/core';
import { Injectable, Component, NgModule } from '@angular/core';
import { Directive, Input, NgModule } from '@angular/core';
class MathjaxLibService {
constructor() { }
const isMathjax = /(?:\$|\\\(|\\\[|\\begin\{.*?})/;
//export const isMathJax = /(?:(?:^|[-+_*/])(?:\s*-?\d+(\.\d+)?(?:[eE][+-]?\d+)?\s*))+$/;
const mathjax_url = 'https://cdn.jsdelivr.net/npm/mathjax@3.0.0/es5/startup.js';
const MathjaxDefaultConfig = {
loader: {
load: ['output/svg', '[tex]/require'],
},
tex: {
inlineMath: [['$', '$']],
displayMath: [['$$', '$$']],
packages: ['base', 'require'],
},
};
//
class RootMathjaxConfig {
}
MathjaxLibService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxLibService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
MathjaxLibService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxLibService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxLibService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}], ctorParameters: function () { return []; } });
class MathjaxLibComponent {
constructor() { }
ngOnInit() {
class MathjaxDirective {
//
constructor(el) {
this.el = el;
if (this.mathJaxExpressions) {
this.mathJaxExpressions =
'string' === typeof this.mathJaxExpressions
? this.mathJaxExpressions
: this.mathJaxExpressions.latex ||
this.mathJaxExpressions.mathml;
}
else {
this.element = el.nativeElement;
}
this.element = el.nativeElement;
}
//
set mathjax(val) {
this.mathJaxExpressions = val;
}
ngOnChanges(changes) {
var _a;
const expressions = changes.mathjax;
if (!expressions ||
expressions.currentValue === expressions.previousValue) {
return;
}
//
if ((_a = (expressions.currentValue + '')) === null || _a === void 0 ? void 0 : _a.match(isMathjax)) {
const filteredVal = this.fixMathjaxBugs(expressions.currentValue + '');
this.typeset(() => {
this.element.innerHTML = `<div>${filteredVal}</div>`;
});
}
else {
this.element.innerHTML = expressions.currentValue;
}
}
fixMathjaxBugs(jax) {
return (jax
//line break error
.replace(/<br \/>/gi, '<br/> ')
//automatic breakline
.replace(/[$]([\s\S]+?)[$]/gi, (m, p, o, s) => {
//return /s/gi.test(p)
return p.includes('\\\\') && !p.includes('\\begin')
? `$\\begin{align*}${p}\\end{align*}$`
: `$${p}$`;
}));
}
typeset(code) {
if (MathJax === null || MathJax === void 0 ? void 0 : MathJax.startup) {
MathJax.startup.promise = MathJax.startup.promise
.then(() => {
code();
return MathJax.typesetPromise ? MathJax.typesetPromise() : null;
})
.catch((err) => console.error('MathJax Typeset failed: ' + err.message));
return MathJax.startup.promise;
}
else {
code();
}
}
}
MathjaxLibComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxLibComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
MathjaxLibComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.1", type: MathjaxLibComponent, selector: "lib-mathjax-lib", ngImport: i0, template: `
<p>
mathjax-lib works!
</p>
`, isInline: true });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxLibComponent, decorators: [{
type: Component,
MathjaxDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
MathjaxDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.1", type: MathjaxDirective, selector: "mathjax,[mathjax]", inputs: { mathjax: "mathjax" }, usesOnChanges: true, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxDirective, decorators: [{
type: Directive,
args: [{
selector: 'lib-mathjax-lib',
template: `
<p>
mathjax-lib works!
</p>
`,
styles: []
selector: 'mathjax,[mathjax]',
}]
}], ctorParameters: function () { return []; } });
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { mathjax: [{
type: Input,
args: ['mathjax']
}] } });
class MathjaxLibModule {
class MathjaxModule {
constructor(moduleConfig) {
var _a, _b;
//
//
const config = document.createElement('script');
const providConfig = Object.assign(Object.assign({}, MathjaxDefaultConfig), ((_a = moduleConfig === null || moduleConfig === void 0 ? void 0 : moduleConfig.config) !== null && _a !== void 0 ? _a : {}));
config.text = `MathJax = ${JSON.stringify(providConfig)}`;
//
//
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = (_b = moduleConfig === null || moduleConfig === void 0 ? void 0 : moduleConfig.src) !== null && _b !== void 0 ? _b : mathjax_url;
script.async = true;
//
}
static forRoot(config) {
return {
ngModule: MathjaxModule,
providers: [{ provide: RootMathjaxConfig, useValue: config !== null && config !== void 0 ? config : {} }],
};
}
static forChild() {
return {
ngModule: MathjaxModule,
};
}
}
MathjaxLibModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
MathjaxLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxLibModule, declarations: [MathjaxLibComponent], exports: [MathjaxLibComponent] });
MathjaxLibModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxLibModule, imports: [[]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxLibModule, decorators: [{
MathjaxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxModule, deps: [{ token: RootMathjaxConfig }], target: i0.ɵɵFactoryTarget.NgModule });
MathjaxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxModule, declarations: [MathjaxDirective], exports: [MathjaxDirective] });
MathjaxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxModule });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.1", ngImport: i0, type: MathjaxModule, decorators: [{
type: NgModule,
args: [{
declarations: [
MathjaxLibComponent
],
imports: [],
exports: [
MathjaxLibComponent
]
declarations: [MathjaxDirective],
exports: [MathjaxDirective],
}]
}] });
}], ctorParameters: function () { return [{ type: RootMathjaxConfig }]; } });

@@ -66,3 +145,3 @@ /*

export { MathjaxLibComponent, MathjaxLibModule, MathjaxLibService };
export { MathjaxDefaultConfig, MathjaxDirective, MathjaxModule, RootMathjaxConfig, isMathjax, mathjax_url };
//# sourceMappingURL=mathjax-angular.js.map
{
"name": "mathjax-angular",
"version": "0.0.1",
"version": "0.5.0",
"peerDependencies": {

@@ -5,0 +5,0 @@ "@angular/common": "^12.1.1",

@@ -1,3 +0,1 @@

export * from './lib/mathjax-lib.service';
export * from './lib/mathjax-lib.component';
export * from './lib/mathjax-lib.module';
export * from './directive';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc