Newfoundland Pitbull Mix

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

    0.1.0 • Public • Published


    Library to convert json to docs or posts. The goal is to provide a simple library that will be able to convert json doc to DOM elements.

    How it works


    There is a JSON content like this:

            type: "header",
            data: {
                type: '1',
                text: "Header"
            type: "paragraph",
            children: [
                    type: "text",
                    modifiers: ["bold"],
                    data: "XXX - Bold "
                    type: "link",
                    modifiers: ["italic"],
                    data: {
                        url: "",
                        text: "Link - Italic"
                    type: "text",
                    modifiers: ["bold", "italic"],
                    data: " YYY - MIX "
            type: "header",
            data: {
                type: '2',
                text: "Header 2"
            type: "image",
            data: {
                url: "https://url.jpg",
                alt: "Pic"

    Library creates output which shall match to above structure, which in HTML looks like this:

    	<span class="bold">XXX - Bold </span>
    	<a href="" class="italic">Link - Italic</a>
    	<span class="bold italic"> YYY - MIX </span>
    <h2>Header 2</h2>
    <img src="https://url.jpg" alt="Pic">


    • Manipulators
    • Modifiers
    • Sections
    • Parser


    Manipulator is an implementation of the interface which provides a way to create an element in the environment (JS, React, etc.) and make certain manipulations on the element like class or attribute addition or removal, setting id, key or text. Number of implemented functions may grow in the future, for now interface allows for:

    • Element creation
    • Appending a child
    • Class addtion
    • Class removal
    • Attribute addtion
    • Attribute removal
    • Setting a key
    • Setting an id
    • Setting a text


    Modifiers are interfaces that change section appearance, like decorating a text. They don't make modification itself, they just know what modifiaction is performed to achieve the effect and use manipulator do it. So they will work independently from manipulator implementation. For example, Bold modificator knows only that class bold shall be added to an element and it calls manipulator to add class regardless of manipulator implementation.


    Sections are responsible for element creation of an element and setting a content related to certain type. For example: image needs a source url and alternative text so ImageSection implementation shall create an element then set two attributes: src and alt. Setting an higher level properties is reserved for parser. There are some generic implementation created based on DOM.


    Main component which wraps all implementation together. It's job is to render (create) elements from the json data. First it, takes list of json elements as an argument. For each one of them, first it renders children if they are available, then it renders element, sets modifers, then id, key. Last step is to add children to element.



    npm i bpd-docs

    DownloadsWeekly Downloads






    Unpacked Size

    157 kB

    Total Files


    Last publish


    • bpd_dev