1.0.8 • Published 2 years ago

tms-mdhtml v1.0.8

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

tms-mdhtml

Convert Markdown to HTML

Install

npm install tms-mdhtml

Usage

Command Line:

mdhtml --src <markdown_file> [...options]

options:

--style <css_file> - insert css_file contents into style element

--title "My Title Text" - insert "My Title Text" into title element

--output <html_file> - save complete HTML to html_file. If not specified, HTML goes to stdout.

JavaScript

import { mdToHtmlText, mdToHtmlDocument } from 'tms-mdhtml';

/**
 * convert markdown text to HTML text
 * @param {string} mdText
 * @param {Boolean} [pretty]
 * @return {string}
 */
let htmlPretty = mdToHtmlText("# Hello World", true);

/*
    htmlPretty:
    <h1>Hello World</h1>
 */

/**
 * convert markdown + style + title strings to complete HTML document
 * @param {string} mdContent
 * @param {string} [styleContent]
 * @param {string} [titleContent]
 * @return {string} - complete html document text
 */

let htmlDocument = mdToHtmlDocument (
  "# Hello World",
  "h1 {font-size: 3rem;}",
  "Hello World Title"
);

/*
    htmlDocument:
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <title>Hello World Title</title>
        <style>
          h1 {
            font-size: 3rem;
          }
        </style>
      </head>
      <body>
        <h1>Hello World</h1>
      </body>
    </html>
 */

Resources

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago