@contentful/rich-text-from-markdown

    15.5.1 • Public • Published

    rich-text-from-markdown

    A library to convert markdown to Contentful Rich Text document format.

    Installation

    Using npm:

    npm install @contentful/rich-text-from-markdown

    Using yarn:

    yarn add @contentful/rich-text-from-markdown

    Usage

    Basic

    const { richTextFromMarkdown } = require('@contentful/rich-text-from-markdown');
    
    const document = await richTextFromMarkdown('# Hello World');

    Advanced

    The library will convert automatically the following markdown nodes:

    • paragraph
    • heading
    • text
    • emphasis
    • strong
    • delete
    • inlineCode
    • link
    • thematicBreak
    • blockquote
    • list
    • listItem

    If the markdown content has unsupported nodes like image ![image](url) you can add a callback as a second argument and it will get called everytime an unsupported node is found. The return value of the callback will be the rich text representation of that node.

    Example:

    const { richTextFromMarkdown } = require('@contentful/rich-text-from-markdown');
    
    // define your own type for unsupported nodes like asset
    const document = await richTextFromMarkdown(
      '![image](\'https://example.com/image.jpg\')',
      node => ({
        nodeType: 'embedded-[entry|asset]-[block|inline]',
        content: [],
        data: {
          target: {
            sys: {
              type: 'Link',
              linkType: 'Entry|Asset',
              id: '.........'
            }
          }
        }
      })
    );

    Install

    npm i @contentful/rich-text-from-markdown

    DownloadsWeekly Downloads

    11,727

    Version

    15.5.1

    License

    MIT

    Unpacked Size

    2.11 MB

    Total Files

    22

    Last publish

    Collaborators

    • georgpanok
    • riqwan.thahamir
    • piotr.ciazynski
    • felixboenke
    • amerr
    • khalilful
    • suevalov
    • farruco.sanjurjo
    • johanneswuerbach
    • ronaldronson
    • silhoue
    • phbschmidt
    • timbeyer
    • kathrinholzmann
    • thebesson
    • dominik.markusic
    • eamodeorubio
    • inbal.gordon
    • poberherr
    • kgarbaya
    • kntsay
    • mikita.savanovich
    • laurenceb
    • stupchiy
    • zcei
    • elblivion
    • fabianheymann
    • it-internal
    • guilebarbosa
    • sbezludny
    • medturki
    • danwe
    • m10l
    • cribbles
    • marina-cf
    • dlitvakb
    • malin_sofrone
    • yann-cf
    • makinwa37
    • diacono
    • whydah-gally
    • tauraz
    • cakejelly
    • matthew-hickey
    • martin3walker
    • cstillitano
    • argvk_cf
    • yiotis
    • leonardofreitass
    • hwartig
    • davidfateh
    • gb-ctf-ext
    • dvasylenko
    • ruderngespra
    • arisplakias
    • janikomu
    • mshaaban0
    • vbeleuta
    • freakyfelt
    • taye
    • kdamball
    • burakukula
    • gregferg
    • marcolink
    • gosiaszporer
    • miretxu
    • djagya
    • z0al
    • mspagnolo
    • thomas.spiesser
    • guisantos
    • cezarluiz0
    • kbarnett
    • jwhiles
    • anho
    • erdener
    • sonac
    • didi96
    • fadynaffa3
    • jhbabon
    • fs
    • cgrabo
    • frida.kiriakos
    • dana_grn
    • antesepiccontentful
    • andipaetzold-cf
    • eva.martinez
    • lucabianconi
    • denkristoffer
    • luizfonseca
    • juliabiro
    • vinz93
    • jbourne
    • 0mathcrap
    • damienxy
    • roryscarson
    • m99coder-cf
    • loweisz
    • thomas.contentful
    • marceltoben
    • arnav.luthra
    • anwar.ahmad
    • massao
    • alexdts-cf
    • bohdan.hutsol
    • contentful-ecosystem
    • vida.momenzadeh
    • yuri.mazursky
    • rebecca.koenig
    • annmary