npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@phtml/markdown

v4.1.0

Published

Write markdown in HTML

Downloads

11

Readme

pHTML Markdown

NPM Version Build Status Support Chat

pHTML Markdown lets you write markdown in HTML.

<h1 markdown>pHTML **Markdown**</h1>
<div markdown>
  ### Make it clear.

  Integrate this love and fear.
  
  Still hopelessly hopeful.

  Wounded child seeking wonderful.
</div>

<!-- becomes -->

<h1>pHTML <strong>Markdown</strong></h1>
<div>
  <h3 id="make-it-clear">Make it clear.</h3>
  <p>Integrate this love and fear.</p>
  <p>Still hopelessly hopeful.</p>
  <p>Wounded child seeking wonderful.</p>
</div>

Usage

Transform HTML files directly from the command line:

npx phtml source.html output.html -p @phtml/markdown

Node

Add pHTML Markdown to your project:

npm install @phtml/markdown --save-dev

Use pHTML Markdown to process your HTML:

const phtmlMarkdown = require('@phtml/markdown');

phtmlMarkdown.process(YOUR_HTML /*, processOptions, pluginOptions */);

Or use it as a pHTML plugin:

const phtml = require('phtml');
const phtmlMarkdown = require('@phtml/markdown');

phtml([
  phtmlMarkdown(/* pluginOptions */)
]).process(YOUR_HTML /*, processOptions */);

pHTML Markdown runs in all Node environments, with special instructions for:

| Node | CLI | Eleventy | Gulp | Grunt | | --- | --- | --- | --- | --- |

Options

attr

The attr option defines attributes used to trigger Markdown parsing. By default, content of elements using md or markdown attributes are parsed as Markdown.

// parse the content of elements with a data-markdown attribute
phtmlMarkdown({ attr: 'data-markdown' })

// parse the content of elements with data-markdown or data-md attributes
phtmlMarkdown({ attr: ['data-markdown', 'data-md'] })
<body data-markdown>
  # You say you want a revolution
</body>
<body>
  <h1>You say you want a revolution</h1>
</body>

removeAttr

The removeAttr option defines attributes used to trigger Markdown parsing that should also be removed. By default, whichever attributes are passed to attr are used. You might use this if the attribute you are using will also be used by the browser or another plugin.

// remove the md attribute from elements with data-content or md attributes
phtmlMarkdown({ attr: ['data-content', 'md'], removeAttr: 'md' })
<p data-markdown>
  You say you want a **revolution**.
</p>
<p md>
  Well, you _know_.
</p>
<p data-markdown>
  You say you want a <strong>revolution</strong>.
</p>
<p>
  Well, you <em>know</em>.
</p>

marked

The marked option defines options passed into marked.

phtmlMarkdown({ marked: { headerIds: false } })
<body markdown>
  # You say you want a revolution
</body>
<body>
  <h1>You say you want a revolution</h1>
</body>