Git Product home page Git Product logo

mathjax-angular's Introduction

mathjax-angular

This plugins implements the browser version of Mathjax v3 into Angular

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

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

To build, serve and open in dev enviornment:

npm run dev (or) yarn dev

Or To build, serve and open in production enviornment:

npm run prod (or) yarn prod

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/[email protected]/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.

mathjax-angular's People

Contributors

sajivkumar avatar codeaye avatar profenpoche avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.