Skip to content

Write markdown files from a Marked token list or string

Notifications You must be signed in to change notification settings

bconnorwhite/write-md-safe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

write-md-safe

NPM TypeScript Coverage Status GitHub Stars Twitter Follow

Write markdown files from a Marked token list or string.

Installation

yarn add write-md-safe
npm install write-md-safe

API

Types

import {
  writeMarkdown,
  writeMarkdownSync,
  markdownContentToString,
  MarkdownContent,
  Token, // a Marked token
  Tokens,
  Options
} from "write-md-safe";

function writeMarkdown(path: string, content?: MarkdownContent, options?: Options): Promise<void>;

function writeMarkdownSync(path: string, content?: MarkdownContent, options?: Options): void;

function markdownContentToString(content?: MarkdownContent): string;

type MarkdownContent = string | (Token | string)[];

type Options = {
  /**
   * Recursively create parent directories if needed. Default: `true`
   */
  recursive?: boolean;
  /**
   * Ensure file ends with a newline. Default: `true`
   */
  appendNewline?: boolean;
  /**
   * Write even if file already exists. Default: `true`
   */
  overwrite?: boolean;
}

Dependenciesdependencies

  • marked: A markdown parser built for speed
  • write-file-safe: Write files and create parent directories if necessary

Dev DependenciesDavid


License license

MIT


Related Packages:

  • read-md-safe: Read markdown files as a Marked token list or string.
  • write-file-safe: Write files, and create parent directories if necessary.