All Projects → notslang → Tidy Markdown

notslang / Tidy Markdown

Licence: gpl-3.0
Beautify Markdown, fixing formatting mistakes and standardizing syntax

Programming Languages

coffeescript
4710 projects

Labels

Projects that are alternatives of or similar to Tidy Markdown

Awless Templates
Repository of examples for awless templates (see https://github.com/wallix/awless)
Stars: ✭ 59 (-3.28%)
Mutual labels:  cli
Php Fpm Status Cli
PHP-FPM status-page CLI
Stars: ✭ 60 (-1.64%)
Mutual labels:  cli
Cli Error Notifier
Sends native desktop notifications if CLI apps fail
Stars: ✭ 61 (+0%)
Mutual labels:  cli
Needy
A C++ library dependency helper.
Stars: ✭ 59 (-3.28%)
Mutual labels:  cli
Za Farmer
基于uiautomator2.0 的自动化测试工具
Stars: ✭ 60 (-1.64%)
Mutual labels:  cli
Teller Cli
🏦 Banking for your command line.
Stars: ✭ 60 (-1.64%)
Mutual labels:  cli
Rbiam
A unified IAM+Kubernetes RBAC access control exploration tool
Stars: ✭ 59 (-3.28%)
Mutual labels:  cli
Stacker Cli
Docker Compose Templates
Stars: ✭ 61 (+0%)
Mutual labels:  cli
Baapan
✨ Super Cool NPM Playground right on the Node REPL ✨
Stars: ✭ 60 (-1.64%)
Mutual labels:  cli
Xxv
The XXV visual hex viewer for the terminal.
Stars: ✭ 61 (+0%)
Mutual labels:  cli
Cli Mandelbrot
📦 View the Mandelbrot set from your terminal
Stars: ✭ 59 (-3.28%)
Mutual labels:  cli
Netlify Builder
Deploy your Angular app to netlify from CLI
Stars: ✭ 60 (-1.64%)
Mutual labels:  cli
Wago
Automate the actions you do after saving code.
Stars: ✭ 60 (-1.64%)
Mutual labels:  cli
Cheatsheet
Cool command-line cheatsheet. Open format, grep-able, where you need them most.
Stars: ✭ 58 (-4.92%)
Mutual labels:  cli
Syncano Node
Syncano Toolkit for JavaScript development
Stars: ✭ 61 (+0%)
Mutual labels:  cli
Clojurl
An example Clojure CLI HTTP/S client using GraalVM native image
Stars: ✭ 59 (-3.28%)
Mutual labels:  cli
Fsq
A tool for querying the file system with a SQL-like language.
Stars: ✭ 60 (-1.64%)
Mutual labels:  cli
Httpie Http2
Experimental HTTP/2 plugin for HTTPie
Stars: ✭ 61 (+0%)
Mutual labels:  cli
Rtscli
Python CLI Stocks Ticker + Portfolio Tracker
Stars: ✭ 61 (+0%)
Mutual labels:  cli
Cli Toolkit
PHP CLI Toolkit
Stars: ✭ 60 (-1.64%)
Mutual labels:  cli

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

Editing In-place

If you want to rewrite a file in-place, you can use sponge from moreutils. If you did tidy-markdown < ./README.md > ./README.md you'd end up with an empty file.

$ tidy-markdown < ./README.md | sponge ./README.md

Docs

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

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

Fix ugly markdown. Unformatted Markdown is read from STDIN, formatted, and
written to STDOUT.

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. 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

You can also pass options through a 2nd arg, like tidyMarkdown(uglyMarkdown, {ensureFirstHeaderIsH1: false}). The option ensureFirstHeaderIsH1 is the only one right now.

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.
  • Convert HTML elements into their Markdown equivalents. For example, <em>text</em> becomes _text_.

Minimal Configuration

Tidy Markdown works hard to keep configuration to a minimum. The goal is to create a highly readable, canonical representation of Markdown, much like gofmt has done for Go. Having extra configuration would defeat that purpose and add extra maintenance work.

That's not to say you shouldn't open issues if you find the output ugly, that's encouraged, especially in the styleguide repo because without criticism it won't get better. However, you should provide examples and a good argument to support the change.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].