Natural Pacifist Manatees

    md-to-pdfmake
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.1 • Public • Published

    md-to-pdfmake

    Build Status Npm package version

    Parser of markdown text to pdfmake object.

    Installation


    Using npm:

    $ npm install md-to-pdfmake

    Example:


    Mardown Text

    Hello World !
    
    **That's a bold text**
    **_That's a italic text_**
    
    # That's a big text !
    
    - Item 1
    - Item 2

    Parsed pdfmake object

    [
      { text: 'Hello World' },
      { text: [{ text: "That's a bold text", bold: true }] },
      { text: [{ text: "That's a italic text", italics: true }] },
      { text: "That's a big text" },
      {
        ul: [{ text: 'Item 1' }, { text: 'Item 2' }],
      },
    ];

    API


    To parse a markdown string to pdfmake object is simple:

    import { toPdfMakeObject } from 'md-to-pdfmake';
    
    const markdownText = '**Hello World**';
    const parsedObject = toPdfMakeObject(markdownText);

    You can also define the optional style properties provided by pdfmake for each parsed element:

    Element Available Properties
    p fontSize, lineHeight, characterSpacing, margin
    h1,h2,h3,h4,h5,h6 fontSize, lineHeight, characterSpacing, margin
    li fontSize, lineHeight, characterSpacing, margin
    ul type, markerColor
    ol type, markerColor, separator, reversed, start

    Example using style properties:

    import { toPdfMakeObject } from 'md-to-pdfmake';
    
    const markdownText = '# Hello World\n## Welcome'; // h1 and h2
    const parsedObject = toPdfMakeObject(markdownText, {
      h1: { fontSize: 20 },
      h2: { fontSize: 18 },
    });

    Supported elements

    • Paragraph
    • Ordered List
    • Unordered List
    • Headings (h1, h2, h3, h4, h5, h6)
    • Strong
    • Italic

    Install

    npm i md-to-pdfmake

    DownloadsWeekly Downloads

    62

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    42.8 kB

    Total Files

    17

    Last publish

    Collaborators

    • brunobfreitas