-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathjson2md.min.js
1 lines (1 loc) · 2.88 KB
/
json2md.min.js
1
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol?"symbol":typeof n};!function(n){if("object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.json2md=n()}}(function(){return function n(e,r,t){function o(u,f){if(!r[u]){if(!e[u]){var c="function"==typeof require&&require;if(!f&&c)return c(u,!0);if(i)return i(u,!0);var a=new Error("Cannot find module '"+u+"'");throw a.code="MODULE_NOT_FOUND",a}var s=r[u]={exports:{}};e[u][0].call(s.exports,function(n){var r=e[u][1][n];return o(r?r:n)},s,s.exports,n,e,r,t)}return r[u].exports}for(var i="function"==typeof require&&require,u=0;u<t.length;u++)o(t[u]);return o}({1:[function(n,e){var r=e.exports={},t=function(n){return function(e,r){return"#".repeat(n)+" "+r(e)}},o=function u(n,e,r){var t=n;return"string"==typeof n&&(t=n.split("\n")),r?t.length<=1?t.join("\n"):t[0]+"\n"+u(t.slice(1),e,!1):t.map(function(n){return" ".repeat(e)+n}).join("\n")},i=function(n){var e={strong:"**",italic:"*"};return n.replace(/\<\/?strong\>/gi,e.strong).replace(/\<\/?bold\>/gi,e.strong).replace(/\<\/?em\>/gi,e.italic).replace(/\<\/?italic\>/gi,e.italic)};r.h1=t(1),r.h2=t(2),r.h3=t(3),r.h4=t(4),r.h5=t(5),r.h6=t(6),r.blockquote=function(n,e){return e(n,"> ")+"\n"},r.img=function(n,e){return Array.isArray(n)?e(n,"","img"):"string"==typeof n?r.img({source:n,title:""}):(n.title=n.title||"","!["+n.title+"]("+n.source+")\n")},r.ul=function(n,e){for(var r="",t=0;t<n.length;++t)r+="\n - "+i(o(e(n[t]),4,!0));return r+"\n"},r.ol=function(n,e){for(var r="",t=0;t<n.length;++t)r+="\n "+(t+1)+". "+i(o(e(n[t]),4,!0));return r+"\n"},r.code=function(n){var e="```"+(n.language||"")+"\n";return e+=Array.isArray(n.content)?n.content.join("\n"):n.content,e+="\n```"},r.p=function(n,e){return i(e(n,"\n"))+"\n"},r.table=function(n,e){if("object"!=("undefined"==typeof n?"undefined":_typeof(n))||!n.hasOwnProperty("headers")||!n.hasOwnProperty("rows"))return"";var r=n.headers.join(" | "),t=n.headers.map(function(){return"---"}).join(" | "),o=n.rows.map(function(r){return Array.isArray(r)?r.map(function(n){return i(e(n))}).join(" | "):n.headers.map(function(n){return i(e(r[n]))}).join(" | ")}).join("\n");return[r,t,o].join("\n")}},{}],2:[function(n,e){function r(n,e,o){if(e=e||"","string"==typeof n||"number"==typeof n)return e+n;var i=[];if(Array.isArray(n)){for(var u=0;u<n.length;++u)i.push(e+r(n[u],"",o));return i.join("\n")}var f=Object.keys(n)[0],c=t[o||f];if("function"==typeof c)return c(o?n:n[f],r);throw new Error("There is no such converter: "+f)}var t=n("./converters");r.converters=t,e.exports=r},{"./converters":1}]},{},[2])(2)});