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

gfm-wordpress

v1.6.0

Published

Convert GitHub flavored Markdown to Wordpress-ready HTML

Downloads

3

Readme

gfm-wordpress

Process GitHub flavored Markdown so it can be pasted directly into WordPress.

I (Jason Smith) use this tool for writing blog posts in a project on GitHub, but then publish them on the IBM Developerworks blog. If you are not blogging for the Cloud Data Services developer advocacy group, I am not sure you will find this very useful. But maybe.

Features

GFM-WordPress does a few things:

  1. Convert GitHub-flavored Markdown to HTML
  2. Correct syntax highlighting (embed the required CSS) in the HTML
  3. Fix a few CSS bugs
  4. Build a Table of Contents
  5. Automatically correct links to a media/ subdirectory, so that they work from WordPress
  6. If an image has retina resolution ("[email protected]"), reduce its size so it does not look ridiculous
  7. Support for basic "figures": images that float in the text flow, with captions

Authoring a Document

Make a Markdown document in any Git project. You can preview it in GitHub normally. Follow two rules:

  1. In code samples, do not exceed 72 characters per line, or it will auto-wrap and look ugly. You can set a guide in the Xcode preferences. But remember not to take a screenshot with the guide enabled.

Page guide in Xcode

  1. Commit images in media/ relative to your .md file. Reference it like this: ![Alt text goes here](media/image-filename.png)
  2. If you take a screenshot from a retina device (iPhone, MacBook pro, etc.), give the filename a @2x suffix, e.g. [email protected]
  3. Commit downloads in media/ just like images. Link to them normally, e.g. [example-download]: media/example-project.tar.gz

If you follow these rules, everything will work when you view the document in GitHub, and it will work when you paste into WordPress.

Usage

Install with NPM:

npm install --global gfm-wordpress

To use the tool, you have to figure out the "media" location for your post. This is the directory WordPress will store your images, downloads, etc.

There are two ways to figure out the media location: by using the URL of an image already uploaded, or by "guessing."

  1. The sure-fire way: Get an image URL from your post draft:
  2. Log in to WordPress
  3. Create a draft post. Click "Save Draft" at least once, just to be sure.
  4. Click "Add Media"
  5. Click the "Upload Files" tab and click the "Select Files" button
  6. Select a file and upload it in.
  7. When the upload is done, click the image so it is checked
  8. In the right sidebar, the URL will be visible. Select the entire URL and copy it to your clipboard.
  9. The "guessing" way: Just do step 1 a lot until you know the system by heart. The media location seems to change only once per month. I think it is 47/2016/MM where MM is the current month. I have no idea whatsoever what the "47" means. Maybe we are the 47th blog installed on this WordPress server?

Once you know your media location, run the tool:

gfm-wordpress README.md --media=47/2016/01

But you can also paste the full URL of an image; gfm-wordpress will extract the media location from that URL.

The HTML will arrive on stdout. Copy all of the HTML and paste it into the blog editor. You should completely overwrite the previous post content. The idea is that all authoring is in Markdown. WordPress only hosts the final HTML.

Finishing

You must upload all media manually. Just follow the procedure from the Usage section above. As you preview the post, the images should render, because the gfm-wordpress output HTML is already referencing them correctly.

If you do not see the images, one problem I suspect is that they need to be pushed to a CDN of some sort. Try clicking "Insert into post". (You will notice it takes longer than you'd think.) Once it inserts the HTML into your post, just delete that HTML.

If you are on the CDS team, check the blog post of this very file (it is private, so you must be logged in or it will 404).

License

Apache 2.0