2.1.38 • Published 2 years ago

@slimr/markdown v2.1.38

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

🪶 @slimr/markdown npm package

A tiny markdown parser and react component

Context

@slimr is a set of slim React (hence '@slimr') libs. Check them all out on github!

API

parse

Converts a limited markdown subset to HTML

  • 2Kb zipped, 1kb when bundled with other code
  • ...is very small relatively speaking
  • Keeps bundle small by clever coding and not supporting every markdown feature

Supported Syntax

  • headings, i.e. # H1, ## H2, ### H3, #### H4, ##### H5, ###### H6
  • alt H1 heading, i.e. H1\n===
  • alt H2 heading, i.e. H1\n---
  • Horizontal rule/lines, i.e. *** --- ___
  • bold
  • italic
  • strikethrough
  • links, i.e. Link Link with title
  • reference links, i.e. link1-text
  • images, i.e. Image Image with title
  • ordered and unordered lists up to one level. nesting not supported.
  • code blocks
  • Most HTML is passed through without modification, except scripts/style which will be HTML encoded
import {parse} from '@slimr/markdown'

const html = parse(`
  # ~~The Jungle~~Heaven

  Welcome to ~~the jungle~~heaven, baby.
`)

Markdown

A component that displays markdown as html, using src/parse for conversion

Paremeters:

  • applyCodeSyntaxHighlights: Whether to apply syntax highlighting to code blocks. Uses highlight.js which is lazy loaded but HUGE (~20kb). So, if you don't need it, don't use it.
  • src: A string containing markdown to be displayed
import {Markdown} from '@slimr/markdown'

function MyComponent() {
  return (
    <Markdown
      src={`
    # ~~The Jungle~~Heaven

    Welcome to ~~the jungle~~heaven, baby.
  `}
    />
  )
}
2.1.27

2 years ago

2.1.28

2 years ago

2.1.25

2 years ago

2.1.26

2 years ago

2.1.24

2 years ago

2.1.29

2 years ago

2.1.38

2 years ago

2.1.36

2 years ago

2.1.37

2 years ago

2.1.34

2 years ago

2.1.35

2 years ago

2.1.30

2 years ago

2.1.31

2 years ago

2.1.23

2 years ago

2.1.22

2 years ago

2.1.21

2 years ago

2.1.20

2 years ago

2.1.19

2 years ago

2.1.18

2 years ago

2.1.17

2 years ago

2.1.16

2 years ago

2.1.14

2 years ago

2.1.13

2 years ago

2.1.12

2 years ago

2.1.11

2 years ago

2.1.10

2 years ago

2.1.7

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago