New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tidy-markdown

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tidy-markdown

fix ugly markdown.

  • 0.3.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
90
decreased by-55.67%
Maintainers
1
Weekly downloads
 
Created
Source

Tidy Markdown

Build Status NPM version NPM license

Beautify Markdown, fixing formatting mistakes and converting basic HTML & Unicode into their Markdown equivalents. Based on the conventions in Carrot Creative's Markdown Styleguide and built on Marked.

There is also an Atom Plugin to run this entirely within your editor.

Install

Tidy Markdown is an npm package, so it can be installed like this:

npm install tidy-markdown -g

CLI

Tidy Markdown includes a simple CLI. It operates entirely over STDIN/STDOUT. For example:

$ echo "# a header #" | tidy-markdown
# a header

Or using a file:

$ tidy-markdown < ./ugly-markdown
# Some markdown
Lorem ipsum dolor adipiscing
- one
- two
- three

And, of course, we can output to a file too:

$ tidy-markdown < ./ugly-markdown > ./clean-markdown

The --help arg will make it show a usage page:

usage: tidy-markdown [-h] [-v] [--no-ensure-first-header-is-h1]

fix ugly markdown.

Optional arguments:
  -h, --help            Show this help message and exit.
  -v, --version         Show program's version number and exit.
  --no-ensure-first-header-is-h1
                        Disable fixing the first header when it isn't an H1.
                        This is useful if the markdown you're processing
                        isn't a full document, but rather a piece of a larger
                        document.

API

Tidy Markdown only exports one function, that takes one argument (the string of ugly markdown). Here's an example of how it can be used:

tidyMarkdown = require 'tidy-markdown'

uglyMarkdown = '''
# Some markdown #

Lorem ipsum dolor adipiscing


- one
*  two
+ three
'''

cleanMarkdown = tidyMarkdown(uglyMarkdown)
console.log cleanMarkdown

which outputs:

# Some markdown
Lorem ipsum dolor adipiscing
- one
- two
- three

Features

  • standardize syntactical elements to use a single way of being written (for example, all unordered lists are formatted to start with hyphens, rather than allowing asterisks and/or addition signs to be mixed in).
  • fix numbering - making ordered lists count naturally from 1 to n and reference links do the same (based on first occurance).
  • make headers move from h1 to smaller without gaps (like an h1 followed by an h4 would be corrected to an h1 followed by an h2).
  • decode Unicode characters that have markdown equivalents (like a horizontal ellipsis becomes "..." and an em-dash becomes "--").
  • format YAML front-matter and Markdown tables

Keywords

FAQs

Package last updated on 27 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc