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

mdprepare

v1.0.1

Published

Utility which allows anything to be inserted into markdown files (files, json, js, xml, csv, etc). Creates Contents. Checks links.

Downloads

19

Readme

mdprepare

A command line utility to prepare and process md files ready for publication.

Build Status Windows Tests npm JavaScript Style Guide Greenkeeper badge Scrutinizer Code Quality Coverage Status

Introduction

Allows anything that can be obtained at the command line to be inserted into a markdown document. Including a whole file, a file extract or any program output via stdout.

This is useful if you wish to reuse documents located separately, or wish to insert data/code samples which have been subjected to tests and can therefore be guaranteed to be up to date in your documentation.

Installation

npm install mdprepare

Demo

Create two files

  • toInsert.md:
### Heading
Example text
  • example.md:
# Demonstration of mdprepare
The contents of  toInsert.md are inserted between here
[>]: # (mdpInsert cat ./toInsert.md)
[<]: #
and here

Then from the command line run mdprepare and see the changes made to example.md

The above two files are included as part of the package and can be copied to your working directory from node_modules/mdprepare/demo

Running mdprepare

From the command line run mdprepare which will process all md files in the current and any child folders (ignoring the node_modules folder). Alternatively it can be fired from any script in package.json. For a full explanation of all the options see mdprepare Command

Insertion methods

There are two methods of insertion

(Ab)Using markdown link destinations

Compatible with most dialects of markdown, a pair of link destinations are used to surround the area which will receive the inserted text. eg:


[>]: # (mdpInsert cat ./example1.md)
some previous text
[<]: #

The first character (< or >) in the square brackets is required as are the square brackets, hash, and spaces. Other text in the square brackets is ignored so can be used for your comments. The command itself can be enclosed in brackets, single quote, or double quote, so the following are also valid pairs:


[>]: # " mdpInsert node -v "
[<]: #

[>my comments]: # 'mdpInsert echo "it works"'
[<more comments]: #

Note that a blank line is required before the openning link destination to ensure maximum compatibility with markdown browsers. See this stackoverflow question for details. Importantly the format shown here with the blank line also works perfectly for both npm and GitHub.

Fenced Code

A second method which is compatible GitHub flavored Markdown is to add the mdpInsert statement on the same line as the opening fence, after the code style (if used) eg.

```json mdpInsert cat ./example1.json
{example: 'previous version'}
```

Limitations

  • mdpInsert using code fences will only work on top level or one level down blocks So this is will work:
```js mdpInsert example1.js
someCode()
```
> ```js mdpInsert example2.js
> moreCode()
> ```

but this will fail:

>> ```js mdpInsert example1.js
>> someCode()
>> ```

Detailed specifications

mdprepare CLI Command

Usage: mdprepare [FILES] [options]

FILES is a glob expression representing the files to be processed, the default is: ./**/*.md

Options: --ignore glob expression representing files to be ignore. By default node_modules and the contents of .gitignore are ignored. Example: mdprepare --ignore=test*.md

--clear removes any existing text which would normally be replaced by mdprocess leaving a lightweight master document. There is no requirement to use this option as old text will always be replaced.

mdpInsert Statement

Usage: within either of the two insertion methods: `mdpInsert' [option] [arguments]

Options: --cmd runs all that follows as if from the command line, inserting the result. This is the default option so does not have to be present --contents (awaiting implementation) inserts a contents section built from headings within your document

Additional commands

Installing fsnip alongside mdprepare allows the following:

```json mdpInsert fsnip example.json --ellipsify alarm !timestamp
{'JsonExtract': 'inserted here'}
```

or:

```mdpInsert fsnip example.txt --from startTag --to endTag
text file extract inserted here
```

or:

[>]: # (mdpInsert fsnip example.md --start '"## Heading 1"' --to '"## Heading 2"')
## Heading 1
Section contents inserted here
[<]: #

See fsnip documentation for further details.

Note:

Both mdprepare and fsnip are designed to be cross platform compatible.