🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

astrohacker-md

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astrohacker-md

Markdown for Astrohacker

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

astrohacker-md

This is a fork of markdown-to-jsx that adds support for block- and inline-level mathematics to markdown files using span tags that can be rendered with KaTeX inside a browser as well as other features used by Astrohacker.

An example of how to use this library inside your Remix project to support math and links is as follows:

import Markdown from 'remix-markdown-katex'
import { Link } from '@remix-run/react'
import { InlineMath, BlockMath } from 'react-katex'

const MyLink = ({ children, ...props }) =>
  props.href.startsWith('https://') || props.href.startsWith('http://') ? (
    <a {...props} target="_blank">
      {children}
    </a>
  ) : props.href.startsWith('/') ? (
    <Link {...props} to={props.href}>
      {children}
    </Link>
  ) : (
    <Link {...props} to={'../' + props.href}>
      {children}
    </Link>
  )

const MySpan = ({ children, ...props }) =>
  props.className === 'inline-math' ? (
    <InlineMath {...props}>{children}</InlineMath>
  ) : props.className === 'block-math' ? (
    <BlockMath {...props}>{children}</BlockMath>
  ) : (
    <span {...props}>{children}</span>
  )

const MyMarkdown = props => {
  return (
    <Markdown
      {...props}
      options={{
        disableParsingRawHTML: true,
        overrides: {
          a: {
            component: MyLink,
          },
          span: {
            component: MySpan,
          },
        },
      }}
    >
      {props.children}
    </Markdown>
  )
}

export default MyMarkdown

Keywords

markdown

FAQs

Package last updated on 28 Sep 2023

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