UNPKG

markdown-to-json-utilitary

Version:

Markdown to JSON Util is a simple and efficient Node.js utility to convert `.md` (Markdown) files into structured JSON objects. It recognizes headings and paragraphs, helping developers turn content into structured data for blogs, CMSs, or static site gen

22 lines (17 loc) 784 B
// Import the main conversion function from the local module // Make sure "main.js" is in the same directory as this file const { convertMarkdownFileToJson } = require("./main"); // Self-invoking async function to allow using await at the top level (async () => { // Call the function with the folder and the markdown filename // This reads and converts "content/file-example.md" into structured JSON const result = await convertMarkdownFileToJson("content", "file-example.md"); // Print the formatted result to the console console.log("JSON result:", JSON.stringify(result, null, 2)); /** * Example use cases for the result: * - Save to a database * - Generate a webpage based on the content * - Index in a search engine */ })();