<commit_before>(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.json2md = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";

const converters = module.exports = {};

let generateHeader = repeat => {
    return (input, json2md) => {
        return "#".repeat(repeat) + " " + json2md(input);
    };
};

let indent = (content, spaces, ignoreFirst) => {
    let lines = content;

    if (typeof content === "string") {
        lines = content.split("\n");
    }

    if (ignoreFirst) {
        if (lines.length <= 1) {
            return lines.join("\n");
        }
        return lines[0] + "\n" + indent(lines.slice(1), spaces, false);
    }

    return lines.map(c => " ".repeat(spaces) + c).join("\n");
}

let parseTextFormat = text => {

    let formats = {
        strong: "**"
      , italic: "*"
    };

    return text
            .replace(/\<\/?strong\>/gi, formats.strong)
            .replace(/\<\/?bold\>/gi, formats.strong)
            .replace(/\<\/?em\>/gi, formats.italic)
            .replace(/\<\/?italic\>/gi, formats.italic)
            ;
}

// Headings
converters.h1 = generateHeader(1);
converters.h2 = generateHeader(2);
converters.h3 = generateHeader(3);
converters.h4 = generateHeader(4);
converters.h5 = generateHeader(5);
converters.h6 = generateHeader(6);

converters.blockquote = (input, json2md) => {
    return json2md(input, "> ") + "\n";
};

converters.img = (input, json2md) => {
    if (Array.isArray(input)) {
        return json2md(input, "", "img");
    }
    if (typeof input === "string") {
        return converters.img({ source: input, title: "" });
    }
    input.title = input.title || "";
    return "![" + input.title + "](" + input.source + ")\n";
};

converters.ul = (input, json2md) => {
    let c = "";
    for (let i = 0; i < input.length; ++i) {
        c += "\n - " + parseTextFormat(indent(json2md(input[i]), 4, true));
    }
    return c + "\n";
};

converters.ol = (input, json2md) => {
    let c = "";
    for (let i = 0; i < input.length; ++i) {
        c += "\n " + (i + 1) + ". " + parseTextFormat(indent(json2md(input[i]), 4, true));
    }
    return c + "\n";
};

converters.code = (input, json2md) => {
    let c = "```" + (input.language || "") + "\n";
    if (Array.isArray(input.content)) {
        c += input.content.join("\n");
    } else {
        c += input.content;
    }
    c += "\n```";
    return c;
};

converters.p = (input, json2md) => {
    return parseTextFormat(json2md(input, "\n")) + "\n";
};

converters.table = (input, json2md) => {

    if (typeof input != "object"
        || !input.hasOwnProperty("headers")
        || !input.hasOwnProperty("rows")) {
        return "";
    }

    let header = input.headers.join(" | ")
      , spaces = input.headers.map(() => "---").join(" | ")
      , data  = input.rows.map(r =>
            Array.isArray(r)
                ? r.map(el => parseTextFormat(json2md(el))).join(" | ")
                : input.headers.map(h => parseTextFormat(json2md(r[h]))).join(" | ")
        ).join("\n")
      ;

    return [header, spaces, data].join("\n");
};

},{}],2:[function(require,module,exports){
"use strict";

const converters = require("./converters");

/**
 * json2md
 * Converts a JSON input to markdown.
 *
 * **Supported elements**
 *
 * | Type         | Element            | Data                                                                                                                     | Example                                                                                                                                          |
 * |--------------|--------------------|--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
 * | `h1`         | Heading 1          | The heading text as string.                                                                                              | `{ h1: "heading 1" }`                                                                                                                            |
 * | `h2`         | Heading 2          | The heading text as string.                                                                                              | `{ h2: "heading 2" }`                                                                                                                            |
 * | `h3`         | Heading 3          | The heading text as string.                                                                                              | `{ h3: "heading 3" }`                                                                                                                            |
 * | `h4`         | Heading 4          | The heading text as string.                                                                                              | `{ h4: "heading 4" }`                                                                                                                            |
 * | `h5`         | Heading 5          | The heading text as string.                                                                                              | `{ h5: "heading 5" }`                                                                                                                            |
 * | `h6`         | Heading 6          | The heading text as string.                                                                                              | `{ h6: "heading 6" }`                                                                                                                            |
 * | `p`          | Paragraphs         | The paragraph text as string or array (multiple paragraphs).                                                             | `{ p: "Hello World"}` or multiple paragraphs: `{ p: ["Hello", "World"] }`                                                                        |
 * | `blockquote` | Blockquote         | The blockquote as string or array (multiple blockquotes)                                                                 | `{ blockquote: "Hello World"}` or multiple blockquotes: `{ blockquote: ["Hello", "World"] }`                                                     |
 * | `img`        | Image              | An object or an array of objects containing the `title` and `source` fields.                                             | `{ img: { title: "My image title", source: "http://example.com/image.png" } }`                                                                   |
 * | `ul`         | Unordered list     | An array of strings representing the items.                                                                              | `{ ul: ["item 1", "item 2"] }`                                                                                                                   |
 * | `ol`         | Ordered list       | An array of strings representing the items.                                                                              | `{ ol: ["item 1", "item 2"] }`                                                                                                                   |
 * | `code`       | Code block element | An object containing the `language` (`String`) and `content` (`Array` or `String`)  fields.                              | `{ code: { "language": "html", "content": "<script src='dummy.js'></script>" } }`                                                                |
 * | `table`      | Table              | An object containing the `headers` (`Array` of `String`s) and `rows` (`Array` of `Array`s or `Object`s).                 | `{ table: { headers: ["a", "b"], rows: [{ a: "col1", b: "col2" }] } }` or `{ table: { headers: ["a", "b"], rows: [["col1", "col2"]] } }`         |
 *
 *
 * You can extend the `json2md.converters` object to support your custom types.
 *
 * ```js
 * json2md.converters.sayHello = function (input, json2md) {
 *    return "Hello " + input + "!";
 * };
 * ```
 *
 * Then you can use it:
 *
 * ```js
 * json2md({ sayHello: "World" });
 * // => "Hello World!"
 * ```
 *
 * @name json2md
 * @function
 * @param {Array|Object|String} data The input JSON data.
 * @param {String} prefix A snippet to add before each line.
 * @return {String} The generated markdown result.
 */
function json2md(data, prefix, _type) {
    prefix = prefix || "";
    if (typeof data === "string" || typeof data === 'number') {
        return prefix + data;
    }

    let content = [];

    // Handle arrays
    if (Array.isArray(data)) {
        for (let i = 0; i < data.length; ++i) {
            content.push(prefix + json2md(data[i], "", _type));
        }
        return content.join("\n");
    } else {
        let type = Object.keys(data)[0]
          , func = converters[_type || type]
          ;

        if (typeof func === "function") {
            return func(_type ? data : data[type], json2md);
        }
        throw new Error("There is no such converter: " + type);
    }
}

json2md.converters = converters;

module.exports = json2md;

},{"./converters":1}]},{},[2])(2)
});<commit_msg>Rebuild<commit_after>(function (f) {
    if (typeof exports === "object" && typeof module !== "undefined") {
        module.exports = f();
    } else if (typeof define === "function" && define.amd) {
        define([], f);
    } else {
        var g;if (typeof window !== "undefined") {
            g = window;
        } else if (typeof global !== "undefined") {
            g = global;
        } else if (typeof self !== "undefined") {
            g = self;
        } else {
            g = this;
        }g.json2md = f();
    }
})(function () {
    var define, module, exports;return function e(t, n, r) {
        function s(o, u) {
            if (!n[o]) {
                if (!t[o]) {
                    var a = typeof require == "function" && require;if (!u && a) return a(o, !0);if (i) return i(o, !0);var f = new Error("Cannot find module '" + o + "'");throw f.code = "MODULE_NOT_FOUND", f;
                }var l = n[o] = { exports: {} };t[o][0].call(l.exports, function (e) {
                    var n = t[o][1][e];return s(n ? n : e);
                }, l, l.exports, e, t, n, r);
            }return n[o].exports;
        }var i = typeof require == "function" && require;for (var o = 0; o < r.length; o++) s(r[o]);return s;
    }({ 1: [function (require, module, exports) {
            "use strict";

            const converters = module.exports = {};

            let generateHeader = repeat => {
                return (input, json2md) => {
                    return "#".repeat(repeat) + " " + json2md(input);
                };
            };

            let indent = (content, spaces, ignoreFirst) => {
                let lines = content;

                if (typeof content === "string") {
                    lines = content.split("\n");
                }

                if (ignoreFirst) {
                    if (lines.length <= 1) {
                        return lines.join("\n");
                    }
                    return lines[0] + "\n" + indent(lines.slice(1), spaces, false);
                }

                return lines.map(c => " ".repeat(spaces) + c).join("\n");
            };

            let parseTextFormat = text => {

                let formats = {
                    strong: "**",
                    italic: "*"
                };

                return text.replace(/\<\/?strong\>/gi, formats.strong).replace(/\<\/?bold\>/gi, formats.strong).replace(/\<\/?em\>/gi, formats.italic).replace(/\<\/?italic\>/gi, formats.italic);
            };

            // Headings
            converters.h1 = generateHeader(1);
            converters.h2 = generateHeader(2);
            converters.h3 = generateHeader(3);
            converters.h4 = generateHeader(4);
            converters.h5 = generateHeader(5);
            converters.h6 = generateHeader(6);

            converters.blockquote = (input, json2md) => {
                return json2md(input, "> ") + "\n";
            };

            converters.img = (input, json2md) => {
                if (Array.isArray(input)) {
                    return json2md(input, "", "img");
                }
                if (typeof input === "string") {
                    return converters.img({ source: input, title: "" });
                }
                input.title = input.title || "";
                return "![" + input.title + "](" + input.source + ")\n";
            };

            converters.ul = (input, json2md) => {
                let c = "";
                for (let i = 0; i < input.length; ++i) {
                    c += "\n - " + parseTextFormat(indent(json2md(input[i]), 4, true));
                }
                return c + "\n";
            };

            converters.ol = (input, json2md) => {
                let c = "";
                for (let i = 0; i < input.length; ++i) {
                    c += "\n " + (i + 1) + ". " + parseTextFormat(indent(json2md(input[i]), 4, true));
                }
                return c + "\n";
            };

            converters.code = (input, json2md) => {
                let c = "```" + (input.language || "") + "\n";
                if (Array.isArray(input.content)) {
                    c += input.content.join("\n");
                } else {
                    c += input.content;
                }
                c += "\n```";
                return c;
            };

            converters.p = (input, json2md) => {
                return parseTextFormat(json2md(input, "\n")) + "\n";
            };

            converters.table = (input, json2md) => {

                if (typeof input != "object" || !input.hasOwnProperty("headers") || !input.hasOwnProperty("rows")) {
                    return "";
                }

                let header = input.headers.join(" | "),
                    spaces = input.headers.map(() => "---").join(" | "),
                    data = input.rows.map(r => Array.isArray(r) ? r.map(el => parseTextFormat(json2md(el))).join(" | ") : input.headers.map(h => parseTextFormat(json2md(r[h]))).join(" | ")).join("\n");

                return [header, spaces, data].join("\n");
            };
        }, {}], 2: [function (require, module, exports) {
            "use strict";

            const converters = require("./converters");

            /**
             * json2md
             * Converts a JSON input to markdown.
             *
             * **Supported elements**
             *
             * | Type         | Element            | Data                                                                                                                     | Example                                                                                                                                          |
             * |--------------|--------------------|--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
             * | `h1`         | Heading 1          | The heading text as string.                                                                                              | `{ h1: "heading 1" }`                                                                                                                            |
             * | `h2`         | Heading 2          | The heading text as string.                                                                                              | `{ h2: "heading 2" }`                                                                                                                            |
             * | `h3`         | Heading 3          | The heading text as string.                                                                                              | `{ h3: "heading 3" }`                                                                                                                            |
             * | `h4`         | Heading 4          | The heading text as string.                                                                                              | `{ h4: "heading 4" }`                                                                                                                            |
             * | `h5`         | Heading 5          | The heading text as string.                                                                                              | `{ h5: "heading 5" }`                                                                                                                            |
             * | `h6`         | Heading 6          | The heading text as string.                                                                                              | `{ h6: "heading 6" }`                                                                                                                            |
             * | `p`          | Paragraphs         | The paragraph text as string or array (multiple paragraphs).                                                             | `{ p: "Hello World"}` or multiple paragraphs: `{ p: ["Hello", "World"] }`                                                                        |
             * | `blockquote` | Blockquote         | The blockquote as string or array (multiple blockquotes)                                                                 | `{ blockquote: "Hello World"}` or multiple blockquotes: `{ blockquote: ["Hello", "World"] }`                                                     |
             * | `img`        | Image              | An object or an array of objects containing the `title` and `source` fields.                                             | `{ img: { title: "My image title", source: "http://example.com/image.png" } }`                                                                   |
             * | `ul`         | Unordered list     | An array of strings representing the items.                                                                              | `{ ul: ["item 1", "item 2"] }`                                                                                                                   |
             * | `ol`         | Ordered list       | An array of strings representing the items.                                                                              | `{ ol: ["item 1", "item 2"] }`                                                                                                                   |
             * | `code`       | Code block element | An object containing the `language` (`String`) and `content` (`Array` or `String`)  fields.                              | `{ code: { "language": "html", "content": "<script src='dummy.js'></script>" } }`                                                                |
             * | `table`      | Table              | An object containing the `headers` (`Array` of `String`s) and `rows` (`Array` of `Array`s or `Object`s).                 | `{ table: { headers: ["a", "b"], rows: [{ a: "col1", b: "col2" }] } }` or `{ table: { headers: ["a", "b"], rows: [["col1", "col2"]] } }`         |
             *
             *
             * You can extend the `json2md.converters` object to support your custom types.
             *
             * ```js
             * json2md.converters.sayHello = function (input, json2md) {
             *    return "Hello " + input + "!";
             * };
             * ```
             *
             * Then you can use it:
             *
             * ```js
             * json2md({ sayHello: "World" });
             * // => "Hello World!"
             * ```
             *
             * @name json2md
             * @function
             * @param {Array|Object|String} data The input JSON data.
             * @param {String} prefix A snippet to add before each line.
             * @return {String} The generated markdown result.
             */
            function json2md(data, prefix, _type) {
                prefix = prefix || "";
                if (typeof data === "string" || typeof data === 'number') {
                    return prefix + data;
                }

                let content = [];

                // Handle arrays
                if (Array.isArray(data)) {
                    for (let i = 0; i < data.length; ++i) {
                        content.push(prefix + json2md(data[i], "", _type));
                    }
                    return content.join("\n");
                } else {
                    let type = Object.keys(data)[0],
                        func = converters[_type || type];

                    if (typeof func === "function") {
                        return func(_type ? data : data[type], json2md);
                    }
                    throw new Error("There is no such converter: " + type);
                }
            }

            json2md.converters = converters;

            module.exports = json2md;
        }, { "./converters": 1 }] }, {}, [2])(2);
});

{'fraction_non_alphanumeric': 0.16502440788284217, 'fraction_numerical': 0.008316760079551618, 'mean_word_length': 0.930628272251309, 'pattern_counts': {'":': 6, '<': 25, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 194, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5480976', 'n_tokens_mistral': 5281, 'n_tokens_neox': 5096, 'n_words': 1263}