1.5.6 • Published 9 months ago

@arubiku/react-markdown v1.5.6

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

@arubiku/react-markdown

@arubiku/react-markdown is a React package that allows you to render Markdown content easily and efficiently, with support for code highlighting and customizable themes.

Example

Image

Live demo

Installation

To install the package, run the following command in your terminal:

npm install @arubiku/react-markdown
# or
yarn add @arubiku/react-markdown

Usage

To use the package in your application, you must first import the HighlighterProvider and the SimpleMarkdown component into your file:

import React from 'react';
import { HighlighterProvider, SimpleMarkdown } from '@arubiku/react-markdown';

const App = () => {
    const markdownContent = `
# Hello, World!
This is an example of **Markdown** in our component.
## Example Code
Here is a block of code in JavaScript:
\`\`\`javascript
const hello = 'Hello, World!';
console.log(hello);
\`\`\`

> [!NOTE]
> This is a note.

$f(x) = 2x^2 + frac{3}{4}x + sqrt{x+1} + ∫_<0>^<1> x^2 dx + sum[i=1]^[n]{i^2} + lim<x->0> frac{sin(x)}{x}
`;
    return (
        <HighlighterProvider>
            <SimpleMarkdown content={markdownContent} />
        </HighlighterProvider>
    );
};

export default App;

Props of the SimpleMarkdown Component

The SimpleMarkdown component accepts the following properties:

PropertyTypeDescription
contentstringThe content in Markdown format that you want to render.
classNamestringAdditional CSS classes for the container. The default is dark:prose-invert.
paragraphClassstringCSS classes for paragraphs. Default is my-2.
imageHeightnumberHeight of images in pixels. Default is 400.
themestringCode highlighting theme. Default is light.
codeBlockThemestringCSS classes for code blocks. Default is bg-[#fdf6e3] dark:bg-[#2d353b].
tableHeaderClassstringCSS classes for table headers. Default is bg-gray-200 dark:bg-gray-700].
tableCellClassstringCSS classes for table cells. Default is border px-4 py-2.
extraAlertsAlertMarkdowns[]Extra alerts to be added to the markdown. Default is [].

Elements of the AlertMarkdowns Interface

PropertyTypeDescription
SVGJSX.ElementThe SVG icon to be displayed.
IDstringThe ID of the alert.
CLASSNAMEstringThe CSS class of the alert.
TITLEstringThe title of the alert.
COLORstringThe color of the alert.

!NOTE To use the dark theme, ensure you have dark mode enabled in Tailwind CSS.

Markdown Syntax

The package supports the following Markdown syntax:

Things not in the list are not supported yet.

Functions

The package includes the following functions:

  • HighlighterProvider: A context provider that supplies syntax highlighting capabilities to all child components.
  • SimpleMarkdown: The main component for rendering Markdown content.

Contributions

Contributions are welcome! If you wish to contribute to this project, please follow these steps:

  1. Make a fork of the repository.
  2. Create a new branch (git checkout -b feature/new-feature).
  3. Make your changes and commit (git commit -m 'I added new functionality').
  4. Push to the branch (git push origin feature/new-feature).
  5. Open a Pull Request.

License

This project is licensed under the MIT License.

1.5.6

9 months ago

1.5.5

9 months ago

1.5.4

9 months ago

1.5.3

9 months ago

1.5.2

9 months ago

1.5.1

9 months ago

1.5.0

9 months ago

1.4.9

9 months ago

1.4.8

9 months ago

1.4.7

9 months ago

1.4.6

9 months ago

1.4.5

9 months ago

1.4.4

9 months ago

1.4.3

9 months ago

1.4.2

9 months ago

1.4.1

9 months ago

1.4.0

9 months ago

1.3.6

9 months ago

1.3.5

9 months ago

1.3.4

9 months ago

1.3.3

9 months ago

1.3.2

9 months ago

1.3.1

9 months ago

1.3.0

9 months ago

1.2.6

9 months ago

1.2.5

9 months ago

1.2.4

9 months ago

1.2.3

9 months ago

1.2.2

9 months ago

1.2.1

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago