Comparing version 1.5.5 to 1.5.6
"use strict"; | ||
var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -5,0 +5,0 @@ var _typeof = "function" == typeof Symbol && "symbol" == _typeof2(Symbol.iterator) ? function (n) { |
"use strict"; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -39,3 +39,3 @@ var converters = module.exports = {}; | ||
return text.replace(/\<\/?strong\>/gi, formats.strong).replace(/\<\/?bold\>/gi, formats.strong).replace(/\<\/?em\>/gi, formats.italic).replace(/\<\/?italic\>/gi, formats.italic); | ||
return text.replace(/<\/?strong\>/gi, formats.strong).replace(/<\/?bold\>/gi, formats.strong).replace(/<\/?em\>/gi, formats.italic).replace(/<\/?italic\>/gi, formats.italic); | ||
}; | ||
@@ -69,5 +69,12 @@ | ||
for (var i = 0; i < input.length; ++i) { | ||
c += "\n - " + parseTextFormat(indent(json2md(input[i]), 4, true)); | ||
var marker = ""; | ||
var type = Object.keys(input[i])[0]; | ||
if (type !== "ul" && type !== "ol") { | ||
marker += "\n - "; | ||
} | ||
c += marker + parseTextFormat(indent(json2md(input[i]), 4, true)); | ||
} | ||
return c + "\n"; | ||
return c; | ||
}; | ||
@@ -77,6 +84,16 @@ | ||
var c = ""; | ||
var jumpCount = 0; | ||
for (var i = 0; i < input.length; ++i) { | ||
c += "\n " + (i + 1) + ". " + parseTextFormat(indent(json2md(input[i]), 4, true)); | ||
var marker = ""; | ||
var type = Object.keys(input[i])[0]; | ||
if (type !== "ul" && type !== "ol") { | ||
marker = "\n " + (i + 1 - jumpCount) + ". "; | ||
} else { | ||
jumpCount++; | ||
} | ||
c += marker + parseTextFormat(indent(json2md(input[i]), 4, true)); | ||
} | ||
return c + "\n"; | ||
return c; | ||
}; | ||
@@ -101,3 +118,3 @@ | ||
if ((typeof input === "undefined" ? "undefined" : _typeof(input)) != "object" || !input.hasOwnProperty("headers") || !input.hasOwnProperty("rows")) { | ||
if ((typeof input === "undefined" ? "undefined" : _typeof(input)) !== "object" || !input.hasOwnProperty("headers") || !input.hasOwnProperty("rows")) { | ||
return ""; | ||
@@ -104,0 +121,0 @@ } |
"use strict"; | ||
var converters = require("./converters"); | ||
var converters = require("./converters"), | ||
indento = require("indento"); | ||
@@ -51,4 +52,4 @@ /** | ||
prefix = prefix || ""; | ||
if (typeof data === "string" || typeof data === 'number') { | ||
return prefix + data; | ||
if (typeof data === "string" || typeof data === "number") { | ||
return indento(data, 1, prefix); | ||
} | ||
@@ -61,3 +62,3 @@ | ||
for (var i = 0; i < data.length; ++i) { | ||
content.push(prefix + json2md(data[i], "", _type)); | ||
content.push(indento(json2md(data[i], "", _type), 1, prefix)); | ||
} | ||
@@ -70,3 +71,3 @@ return content.join("\n"); | ||
if (typeof func === "function") { | ||
return func(_type ? data : data[type], json2md); | ||
return indento(func(_type ? data : data[type], json2md), 1, prefix); | ||
} | ||
@@ -73,0 +74,0 @@ throw new Error("There is no such converter: " + type); |
{ | ||
"name": "json2md", | ||
"version": "1.5.5", | ||
"version": "1.5.6", | ||
"description": "A JSON to Markdown converter.", | ||
@@ -26,3 +26,4 @@ "main": "lib/index.js", | ||
"Crisoforo Gaspar <github@crisoforo.com>", | ||
"Dmitry Tsvettsikh <me@reklatsmasters.com>" | ||
"Dmitry Tsvettsikh <me@reklatsmasters.com>", | ||
"Daniel Bastos <danielbastos@live.com>" | ||
], | ||
@@ -41,3 +42,5 @@ "license": "MIT", | ||
}, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"indento": "^1.1.7" | ||
}, | ||
"devDependencies": { | ||
@@ -59,2 +62,2 @@ "tester": "^1.3.0" | ||
] | ||
} | ||
} |
@@ -24,4 +24,3 @@ | ||
```js | ||
// Dependencies | ||
var json2md = require("json2md"); | ||
const json2md = require("json2md"); | ||
@@ -164,4 +163,7 @@ console.log(json2md([ | ||
- [`doc-cli`](https://github.com/cnio/doc-cli#readme) (by CNIO)—doc generator for nodejs | ||
- [`gitdox`](https://github.com/danielbastos11/gitdox) (by Daniel Bastos)—jsdoc-based github readme generator | ||
- [`react-docgen-markdown`](https://github.com/Moezalez/react-docgen-markdown#readme) (by Moritz Sattler)— | ||
- [`terraform2md`](https://github.com/shambarick/terraform2md#readme) (by Bryan LOT)—Generate the Markdown from a terraform.tfstate file.I am using this library to generate documentation for my projects, being integrated with [blah](https://github.com/IonicaBizau/node-blah). | ||
- [`terraform2md`](https://github.com/shambarick/terraform2md#readme) (by Bryan LOT)—Generate the Markdown from a terraform.tfstate file. | ||
- [`utterance-to-markdown`](https://npmjs.com/package/utterance-to-markdown) (by Shaun Warman)—A simple utterance file to markdown text parser | ||
- [`uxcore-tools`](https://npmjs.com/package/uxcore-tools) (by eternalsky)—development tools for uxcoreI am using this library to generate documentation for my projects, being integrated with [blah](https://github.com/IonicaBizau/node-blah). | ||
@@ -168,0 +170,0 @@ ## :scroll: License |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26536
252
180
1
+ Addedindento@^1.1.7
+ Addedindento@1.1.13(transitive)