Giter VIP home page Giter VIP logo

ptm-converter's Introduction

Markdown to HTML Converter

md-html

About

Markdown to HTML converter using Showdown, ESM Only .

Install

npm i ptm-converter

Usage

example.md

---
title: 'Example'
date: '2023-08-20'
---

# Home 

Hello World

<div style="color: red;">Hello World</div>

data

Object : return metadata of markdown file.

import Converter from "ptm-converter";

const mdContent = new Converter('./example.md');

const data = mdContent.data;
console.log(data);
// { title: 'Example', date: '2023-08-20' }
const title = mdContent.postTitle;
console.log(title);
// Example
const date = mdContent.postDate;
console.log(date);
// Sun, Aug 20, 2023 - return formated date
const dat = mdContent.data.date;
console.log(dat);
// 2023-08-20 - return unformated date

content

import Converter from "ptm-converter";

const mdContent = new Converter('./example.md');

const content = mdContent.content;
console.log(content);
/*# Home 

Hello World

<div style="color: red;">Hello World</div>
 */

const convertedContent = mdContent.convertedContent;
console.log(convertedContent);
/*<h1 id="home">Home</h1>
<p>Hello World</p>
<div style="color: red;">Hello World</div>*/

const pageHtml = mdContent.pageHtml;
console.log(pageHtml);
// Return html with hightlight js , copy button to <pre> for page content

const postHtml = mdContent.postHtml;
console.log(postHtml);
// Return html with hightlight js , copy button to <pre> for post content
// include - post title , reading time , last update

json

import Converter from "ptm-converter";

const mdContent = new Converter('./example.md');

const json = mdContent.json;
console.log(json);

/*{
    "data":{
    "title":"Home",
    "date":"2023-08-18"
    },
    "content":"\n# Home \n\nHello World\n\n<div style=\"color: red;\">Hello World</div>\n\n"
}*/

function

import Converter from "ptm-converter";

const formatedDate = new Converter().formatDate('2023-09-11');
console.log(formatedDate);
// Mon, Sep 11, 2023

const readingTime = new Converter().readingTime(text);
console.log(readingTime)
// Return in minutes {number}

const lastUpdate= new Converter('./example.md').lastUpdate();
console.log(lastUpdate);
// 2023-10-22T20:22:04.000Z

Bundled license information:

1. js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT

2. showdown/dist/showdown.js: showdown v 2.1.0 - 21-04-2022

3. he/he.js:https://mths.be/he v1.2.0 by @mathias | MIT license

ptm-converter's People

Contributors

phothinmg avatar

Stargazers

Chan Min Khant avatar Sann Lynn Htun avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.