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

A quick way to implement Mathjax v3 into your Angular project!

  • 2.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
612
decreased by-35.92%
Maintainers
1
Weekly downloads
 
Created
Source

mathjax-angular

This plugins implements the browser version of Mathjax v3 into Angular

Note:This library was generated with Angular CLI version 17.

Feature

This library helps you implement the version 3 of Mathjax into any of your angular web application.

Install

Below are the steps you need to use this library. NPM:

npm install mathjax-angular

Yarn:

yarn add mathjax-angular

Configure the module

Load the module in the @NgModule class of the application. You need to pass a RootMathjaxConfig instance to the config method to configure the module.

Example

We provide a premade example with the library itself, You can see the example here, or alternatively run it locally by cloning the repository and running.

To do that first install the requirements:

npm install (or) yarn

Then either run it in production:

npm run prod (or) yarn prod

or run it in dev:

npm run dev (or) yarn dev

Usage

When importing in the root module, the module should be configured with .forRoot method.

import { NgModule } from "@angular/core";
import { AppComponent } from "./src/app/app.component";

/*Import*/
import { MathjaxModule } from "mathjax-angular";

/*Configuration*/
@NgModule({
  declarations: [AppComponent],
  imports: [MathjaxModule.forRoot(/*Optional Config*/)],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}

You can optionally pass config. for this refer to majax configuration guide

Current configuration defaults to:

{
  "config": {
    "loader": {
      "load": ["output/svg", "[tex]/require", "[tex]/ams"]
    },
    "tex": {
      "inlineMath": [["$", "$"]],
      "packages": ["base", "require", "ams"]
    },
    "svg": { "fontCache": "global" }
  },
  "src": "https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/startup.js"
}
  • For config field refer this.
  • For src field refer CDN.

When importing in a child module, the module must be configured to re-use the same module instance as the root module. So simply configure the module with the .forChild method.

import { MathjaxModule } from 'mathjax-angular';
...
imports: [
  MathjaxModule.forChild()
]
...

Typeset an element

Add the mathjax directive to elements which you want to apply MathJax typesetting on load.

<div [mathjax]="content"></div>

In your ts component

content = "$x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}$";

Info and Help

For more info and help with the mathjax library refer to their site.

Keywords

FAQs

Package last updated on 14 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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