Giter VIP home page Giter VIP logo

posthtml-include-md's Introduction

posthtml-include-md

package version package downloads standard-readme compliant package license make a pull request

Include markdown plugin for PostHTML. Based on posthtml-include

Table of Contents

Install

This project uses node and npm.

$ npm install posthtml-include-md
$ # OR
$ yarn add posthtml-include-md

Usage

const { readFileSync } = require('fs')

const posthtml = require('posthtml')
const includeMD = require('posthtml-include-md')

const html = readFileSync('index.html')

posthtml([ include({ encoding: 'utf8' }) ])
    .process(html)
    .then((result) => console.log(result.html))

In the HTML:

<html>
<head>
    <title>index.html</title>
</head>
<body>
    <markdown src="posts/hello.html"></markdown>
</body>
</html>

Configuration

  • root: Root folder path for include. Default ./
  • encoding: Default utf-8

This plugin uses marked.js to parse markdown files. All of marked.js's configuration options can be passed.

Contribute

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT

posthtml-include-md's People

Contributors

dependabot[bot] avatar renovate-bot avatar scrum avatar tiaanduplessis avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

posthtml-include-md's Issues

help find your package

@tiaanduplessis Hi, I am a posthtml package maintainer, I found your package because you have a posthtml package in dependencies. I think it will be easier for people to find your package if you add it to the list of plugins here and here, and of course the first thing to do in the posthtml organization itself - I can move your package to the posthtml organization for more popularity, for this it will be necessary to add me to this repository and then I will transfer it. The package itself will remain under your control.

let me know about any decision you make, i will understand if you are not interested

Inline markdown

Hey! Thanks for this plugin. I am playing with PostHTML and it seems very handy.

Would it make sense to support inline markdown content? Like this:

        <markdown>Inline **markdown**</markdown>

Currently (with parcel@nightly) this produces:

TypeError: Cannot read property 'src' of undefined
    at /parcel-2-posthtml-playground/node_modules/posthtml-include-md/index.js:20:28
    at /parcel-2-posthtml-playground/node_modules/posthtml/lib/api.js:91:45
    at traverse (/parcel-2-posthtml-playground/node_modules/posthtml/lib/api.js:105:26)
    at traverse (/parcel-2-posthtml-playground/node_modules/posthtml/lib/api.js:111:5)
    at traverse (/parcel-2-posthtml-playground/node_modules/posthtml/lib/api.js:105:17)
    at traverse (/parcel-2-posthtml-playground/node_modules/posthtml/lib/api.js:111:5)

It seems that there is the posthtml-md plugin which allows inline, but as far as I can see not external content and your plugin that supports external, but not inline content. Both of them implement a <markdown> tag, which makes it tricky to use them together.

Having a single plugin support both cases would be nice.

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.