All Projects → DSchau → prettier-markdown

DSchau / prettier-markdown

Licence: other
Parse code blocks in markdown files and run prettier on them

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to prettier-markdown

Gatsby Starter Typescript Rebass Netlifycms
My default Gatsby setup. Includes rich MDX support.
Stars: ✭ 79 (+113.51%)
Mutual labels:  gatsby, prettier
gatsby-starter-antoine
My opinionated Gatsby.js starter
Stars: ✭ 17 (-54.05%)
Mutual labels:  gatsby, prettier
eaf-linter
🤪 A linter, prettier, and test suite that does everything as-simple-as-possible.
Stars: ✭ 17 (-54.05%)
Mutual labels:  code, prettier
Gatsby Starter Strict
A Gatsby starter with strict linting and auto-formatting rules.
Stars: ✭ 43 (+16.22%)
Mutual labels:  gatsby, prettier
Gatsby V2 Tutorial Starter
Gatsby V2 Starter - product of step by step tutorial
Stars: ✭ 139 (+275.68%)
Mutual labels:  gatsby, prettier
gfm-code-blocks
Extract gfm (GitHub Flavored Markdown) fenced code blocks from a string.
Stars: ✭ 20 (-45.95%)
Mutual labels:  code, blocks
gatsby-plugin-prettier-build
prettify gatsby build output
Stars: ✭ 30 (-18.92%)
Mutual labels:  gatsby, prettier
gatsby-simple-blog
an easily configurable gatsby-starter-blog with overreacted looking and tags, breadcrumbs, disqus, i18n, eslint, algolia supported
Stars: ✭ 48 (+29.73%)
Mutual labels:  gatsby
gatsby-starter-simple
A simple blogging Gatsby starter
Stars: ✭ 13 (-64.86%)
Mutual labels:  gatsby
Parsia-Code
Contains random code and some of my older projects
Stars: ✭ 20 (-45.95%)
Mutual labels:  code
react-component-library-lerna
Build your own React component library managed with lerna, presented with storybook and published in private npm registry.
Stars: ✭ 55 (+48.65%)
Mutual labels:  prettier
gatsby-theme-gallery
🏞 A Gatsby Theme for adding a gallery to your site.
Stars: ✭ 40 (+8.11%)
Mutual labels:  gatsby
CCHv2
CCHv2 - A powerful contest helper for CodeForces, developed by NW.js.
Stars: ✭ 108 (+191.89%)
Mutual labels:  code
arepa.dev
Recursos en español para aprender y dominar JavaScript.
Stars: ✭ 29 (-21.62%)
Mutual labels:  gatsby
react16-seed-with-apollo-graphql-scss-router4-ssr-tests-eslint-prettier-docker-webpack3-hot
Seed to create your own project using React with Apollo GraphQL client
Stars: ✭ 19 (-48.65%)
Mutual labels:  prettier
coding-untuk-semua
Coding untuk semua, kumpulan materi-materi untuk belajar coding/pemrograman.
Stars: ✭ 18 (-51.35%)
Mutual labels:  code
gatsby-starter-sass
👓 A Gatsby starter with Sass and no assumptions!
Stars: ✭ 26 (-29.73%)
Mutual labels:  gatsby
WebSheets-Listing-Page
This is a Gatsby template for creating a catalogue websites based on Google Sheets data.
Stars: ✭ 29 (-21.62%)
Mutual labels:  gatsby
prettier-webpack-plugin
Process your Webpack dependencies with Prettier
Stars: ✭ 47 (+27.03%)
Mutual labels:  prettier
snipcart-gatsby-demo
Simple e-commerce for socks made with Gatsby, Snipcart and DatoCMS
Stars: ✭ 15 (-59.46%)
Mutual labels:  gatsby

prettier-markdown

Build Status NPM version

Prettier now includes support for prettifying Markdown (including code blocks!), so as such, I'd recommend using the official Prettier instead. See the release notes for more information

A simple utility and CLI to run prettier on code blocks within Markdown, leaving any non-code blocks untouched.

Currently works on the following languages (basically everything prettier supports!):

  • JavaScript
  • TypeScript
  • JSON
  • CSS
  • SASS
  • LESS
  • GraphQL

Install

yarn global add @dschau/prettier-markdown

Example

Prettier Markdown

Usage

CLI

Command line usage is simple. All options (besides --dry, which will not write files to disk) are passed directly through to prettier.

prettier-markdown src/**/*.md README.md --single-quote --trailing-comma es5

Programatically

prettierMarkdown(files, prettierOpts = {}, programOpts = {})

Usage is fairly simple. An array of markdown files are passed, as well as any prettier options, and prettier is run on the specified files.

const path = require('path');
const { prettierMarkdown } = require('@dschau/prettier-markdown');

prettierMarkdown(
  ['README.md', 'blog/posts/2017-01-01-hello-world/index.md'].map(file =>
    path.join(process.cwd(), file)
  )
).then(files => {
  // array of files that were written
});

Advanced Functionality

Line highlights

Note that line highlights (e.g. like the below) are kept intact and the block is still prettified!

```javascript {1-2}
const a =   'b';
const b =   'c';

  alert('hello world');
```

Frontmatter

Frontmatter, i.e. in a Gastby blog post, is preserved as authored.

---
title: Hello World
tags:
  - Some Tag
  - Another Tag
---

```javascript
// this will be prettified
var a =    'a';

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