Skip to content

🔥 Craft captivating ASCII art from your Markdown expression

License

Notifications You must be signed in to change notification settings

elmouradiaminedev/diagonjs

Repository files navigation

Diagonjs

npm version npm downloads CI status codecov Craft captivating ASCII art from your Markdown expression with ease, powered by Diagon.

🚀 Features

  • Supports Math, Sequence, Tree, Table, Grammars, Frame, and GraphDAG expressions.
  • Flexible translation with customizable options including styles like Unicode, ASCII, Latex, and more.
  • Support for both Node.js and browser environments.
  • Compatible with CommonJS (CJS) and ECMAScript Module (ESM) environments.

⚙️ Install

Install it locally in your project folder:

npm i diagonjs
# Or Yarn
yarn add diagonjs
# Or pnpm
pnpm add diagonjs

📖 Usage

Initialize diagonjs

To initialize diagon.js in your application:

import Diagon from "diagonjs";

const diagon = await Diagon.init();

Use a translator

Once Diagon.js is initialized, you can use its translators to interpret and transform expressions. Below is an example using the math translator:

diagon.translate.math("f(x) = 1 + x / (1 + x)", { style: "Unicode" });

//               x
// f(x) = 1 + ─────
//            1 + x

Web Integration

If you're incorporating Diagonjs into a web application, ensure that the diagon wasm file is correctly copied to the build folder by your bundler. Here's an example with Vite configuration:

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { viteStaticCopy } from "vite-plugin-static-copy";

export default defineConfig({
  plugins: [
    react(),
    viteStaticCopy({
      targets: [
        {
          src: "**/**.wasm",
          dest: "./",
        },
      ],
    }),
  ],
});

📚 Documentation

💖 Thanks

This project has been possible thanks to these great projects:

License

This project is licensed under the MIT License.