Skip to content

Latest commit

 

History

History
109 lines (79 loc) · 2.17 KB

File metadata and controls

109 lines (79 loc) · 2.17 KB
title Getting Started
description Learn how to install and use markdown-magic with quick start examples, CLI usage, and basic configuration

Getting Started

Installation

Install markdown-magic as a development dependency:

npm install markdown-magic --save-dev

Quick Start

Add comment blocks to your markdown files to define where content should be generated:

<!-- docs remote url=http://url-to-raw-md-file.md -->
This content will be dynamically replaced from the remote url
<!-- /docs -->

Then run markdown-magic to process your files.

CLI Usage

Run markdown --help to see all available CLI options:

markdown
# or
md-magic

CLI Examples

Process all markdown files in current directory:

md-magic

Process specific files with custom config:

md-magic --files '**/*.md' --config ./config.file.js

NPM Scripts Integration

Add to your package.json:

{
  "scripts": {
    "docs": "md-magic --files '**/*.md'"
  }
}

Run with: npm run docs

Configuration File

Create an md.config.js or markdown.config.js file in your project root for automatic configuration:

module.exports = {
  matchWord: 'doc-gen',
  transforms: {
    // your custom transforms
  }
}

Programmatic Usage

Zero Configuration

const { markdownMagic } = require('../src')

/* By default all .md files in cwd will be processed */
markdownMagic().then((results) => {
  console.log('result keys', Object.keys(results))
})

Basic Usage

import path from 'path'
import markdownMagic from 'markdown-magic'

// Process a Single File
const markdownPath = path.join(__dirname, 'README.md')
markdownMagic(markdownPath)

Next Steps