From 5c789b2dfc98f202cade0fc375d2b73b3dc39f32 Mon Sep 17 00:00:00 2001 From: Ika Date: Sat, 14 Oct 2017 06:41:25 -0500 Subject: [PATCH] fix(markdown): use the most popular unordered list style (#3027) --- src/printer-markdown.js | 49 ++-- .../markdown/__snapshots__/jsfmt.spec.js.snap | 254 +++++++++--------- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 6 +- .../__snapshots__/jsfmt.spec.js.snap | 44 +-- .../__snapshots__/jsfmt.spec.js.snap | 220 +++++++-------- .../__snapshots__/jsfmt.spec.js.snap | 10 + tests/markdown_thematicBreak/list.md | 2 + .../__snapshots__/jsfmt.spec.js.snap | 14 +- 9 files changed, 316 insertions(+), 285 deletions(-) create mode 100644 tests/markdown_thematicBreak/list.md diff --git a/src/printer-markdown.js b/src/printer-markdown.js index 3cd7f1fe..b610eade 100644 --- a/src/printer-markdown.js +++ b/src/printer-markdown.js @@ -163,16 +163,16 @@ function genericPrint(path, options, print) { : node.value; } case "list": { - const nthSiblingIndex = getNthSiblingIndex( - path, - siblingNode => siblingNode.ordered === node.ordered + const nthSiblingIndex = getNthListSiblingIndex( + node, + path.getParentNode() ); return printChildren(path, options, print, { processor: (childPath, index) => { const prefix = node.ordered ? (index === 0 ? node.start : 1) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") - : nthSiblingIndex % 2 === 0 ? "- " : "+ "; + : nthSiblingIndex % 2 === 0 ? "* " : "- "; return concat([prefix, align(prefix.length, childPath.call(print))]); } }); @@ -185,8 +185,17 @@ function genericPrint(path, options, print) { align(prefix.length, printChildren(path, options, print)) ]); } - case "thematicBreak": - return getAncestorNode(path, "list") ? "* * *" : "- - -"; + case "thematicBreak": { + const counter = getAncestorCounter(path, "list"); + if (counter === -1) { + return "- - -"; + } + const nthSiblingIndex = getNthListSiblingIndex( + path.getParentNode(counter), + path.getParentNode(counter + 1) + ); + return nthSiblingIndex % 2 === 0 ? "- - -" : "* * *"; + } case "linkReference": return concat([ "[", @@ -239,11 +248,16 @@ function genericPrint(path, options, print) { } } -function getNthSiblingIndex(path, condition) { - condition = condition || (() => true); +function getNthListSiblingIndex(node, parentNode) { + return getNthSiblingIndex( + node, + parentNode, + siblingNode => siblingNode.ordered === node.ordered + ); +} - const node = path.getValue(); - const parentNode = path.getParentNode(); +function getNthSiblingIndex(node, parentNode, condition) { + condition = condition || (() => true); let index = -1; @@ -260,19 +274,24 @@ function getNthSiblingIndex(path, condition) { } } -function getAncestorNode(path, typeOrTypes) { +function getAncestorCounter(path, typeOrTypes) { const types = [].concat(typeOrTypes); - let counter = 0; + let counter = -1; let ancestorNode; - while ((ancestorNode = path.getParentNode(counter++))) { + while ((ancestorNode = path.getParentNode(++counter))) { if (types.indexOf(ancestorNode.type) !== -1) { - return ancestorNode; + return counter; } } - return null; + return -1; +} + +function getAncestorNode(path, typeOrTypes) { + const counter = getAncestorCounter(path, typeOrTypes); + return counter === -1 ? null : path.getParentNode(counter); } function printTable(path, options, print) { diff --git a/tests/markdown/__snapshots__/jsfmt.spec.js.snap b/tests/markdown/__snapshots__/jsfmt.spec.js.snap index e3332394..5a4778f0 100644 --- a/tests/markdown/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown/__snapshots__/jsfmt.spec.js.snap @@ -909,14 +909,14 @@ See [CONTRIBUTING.md](CONTRIBUTING.md). Prettier is an opinionated code formatter with support for: -- JavaScript, including +* JavaScript, including [ES2017](https://github.com/tc39/proposals/blob/master/finished-proposals.md) -- [JSX](https://facebook.github.io/jsx/) -- [Flow](https://flow.org/) -- [TypeScript](https://www.typescriptlang.org/) -- CSS, [LESS](http://lesscss.org/), and [SCSS](http://sass-lang.com) -- [JSON](http://json.org/) -- [GraphQL](http://graphql.org/) +* [JSX](https://facebook.github.io/jsx/) +* [Flow](https://flow.org/) +* [TypeScript](https://www.typescriptlang.org/) +* CSS, [LESS](http://lesscss.org/), and [SCSS](http://sass-lang.com) +* [JSON](http://json.org/) +* [GraphQL](http://graphql.org/) It removes all original styling[\\*](#styling-footnote) and ensures that all outputted code conforms to a consistent style. (See this [blog @@ -929,53 +929,53 @@ post](http://jlongster.com/A-Prettier-Formatter)) -- [What does Prettier do?](#what-does-prettier-do) -- [Why Prettier?](#why-prettier) - - [Building and enforcing a style +* [What does Prettier do?](#what-does-prettier-do) +* [Why Prettier?](#why-prettier) + * [Building and enforcing a style guide](#building-and-enforcing-a-style-guide) - - [Helping Newcomers](#helping-newcomers) - - [Writing code](#writing-code) - - [Easy to adopt](#easy-to-adopt) - - [Clean up an existing codebase](#clean-up-an-existing-codebase) - - [Ride the hype train](#ride-the-hype-train) -- [How does it compare to ESLint (or TSLint, + * [Helping Newcomers](#helping-newcomers) + * [Writing code](#writing-code) + * [Easy to adopt](#easy-to-adopt) + * [Clean up an existing codebase](#clean-up-an-existing-codebase) + * [Ride the hype train](#ride-the-hype-train) +* [How does it compare to ESLint (or TSLint, stylelint...)?](#how-does-it-compare-to-eslint-or-tslint-stylelint) -- [Usage](#usage) - - [CLI](#cli) - - [ESLint](#eslint) - - [Pre-commit Hook](#pre-commit-hook) - - [API](#api) - - [Excluding code from formatting](#excluding-code-from-formatting) -- [Options](#options) - - [Print Width](#print-width) - - [Tab Width](#tab-width) - - [Tabs](#tabs) - - [Semicolons](#semicolons) - - [Quotes](#quotes) - - [Trailing Commas](#trailing-commas) - - [Bracket Spacing](#bracket-spacing) - - [JSX Brackets](#jsx-brackets) - - [Range](#range) - - [Parser](#parser) - - [Filepath](#filepath) -- [Configuration File](#configuration-file) - - [Basic Configuration](#basic-configuration) - - [Configuration Overrides](#configuration-overrides) - - [Configuration Schema](#configuration-schema) -- [Editor Integration](#editor-integration) - - [Atom](#atom) - - [Emacs](#emacs) - - [Vim](#vim) - - [Visual Studio Code](#visual-studio-code) - - [Visual Studio](#visual-studio) - - [Sublime Text](#sublime-text) - - [JetBrains WebStorm, PHPStorm, +* [Usage](#usage) + * [CLI](#cli) + * [ESLint](#eslint) + * [Pre-commit Hook](#pre-commit-hook) + * [API](#api) + * [Excluding code from formatting](#excluding-code-from-formatting) +* [Options](#options) + * [Print Width](#print-width) + * [Tab Width](#tab-width) + * [Tabs](#tabs) + * [Semicolons](#semicolons) + * [Quotes](#quotes) + * [Trailing Commas](#trailing-commas) + * [Bracket Spacing](#bracket-spacing) + * [JSX Brackets](#jsx-brackets) + * [Range](#range) + * [Parser](#parser) + * [Filepath](#filepath) +* [Configuration File](#configuration-file) + * [Basic Configuration](#basic-configuration) + * [Configuration Overrides](#configuration-overrides) + * [Configuration Schema](#configuration-schema) +* [Editor Integration](#editor-integration) + * [Atom](#atom) + * [Emacs](#emacs) + * [Vim](#vim) + * [Visual Studio Code](#visual-studio-code) + * [Visual Studio](#visual-studio) + * [Sublime Text](#sublime-text) + * [JetBrains WebStorm, PHPStorm, PyCharm...](#jetbrains-webstorm-phpstorm-pycharm) -- [Language Support](#language-support) -- [Related Projects](#related-projects) -- [Technical Details](#technical-details) -- [Badge](#badge) -- [Contributing](#contributing) +* [Language Support](#language-support) +* [Related Projects](#related-projects) +* [Technical Details](#technical-details) +* [Badge](#badge) +* [Contributing](#contributing) @@ -1043,20 +1043,20 @@ is valuable for a project and team but getting there is a very painful and unrewarding process. People get very emotional around particular ways of writing code and nobody likes spending time writing and receiving nits. -- “We want to free mental threads and end discussions around style. While +* “We want to free mental threads and end discussions around style. While sometimes fruitful, these discussions are for the most part wasteful.” -- “Literally had an engineer go through a huge effort of cleaning up all of our +* “Literally had an engineer go through a huge effort of cleaning up all of our code because we were debating ternary style for the longest time and were inconsistent about it. It was dumb, but it was a weird on-going "great debate" that wasted lots of little back and forth bits. It's far easier for us all to agree now: just run Prettier, and go with that style.” -- “Getting tired telling people how to style their product code.” -- “Our top reason was to stop wasting our time debating style nits.” -- “Having a githook set up has reduced the amount of style issues in PRs that +* “Getting tired telling people how to style their product code.” +* “Our top reason was to stop wasting our time debating style nits.” +* “Having a githook set up has reduced the amount of style issues in PRs that result in broken builds due to ESLint rules or things I have to nit-pick or clean up later.” -- “I don't want anybody to nitpick any other person ever again.” -- “It reminds me of how Steve Jobs used to wear the same clothes every day +* “I don't want anybody to nitpick any other person ever again.” +* “It reminds me of how Steve Jobs used to wear the same clothes every day because he has a million decisions to make and he didn't want to be bothered to make trivial ones like picking out clothes. I think Prettier is like that.” @@ -1070,14 +1070,14 @@ from experienced engineers joining the company, as they likely used a different coding style before, and developers coming from a different programming language. -- “My motivations for using Prettier are: appearing that I know how to write +* “My motivations for using Prettier are: appearing that I know how to write JavaScript well.” -- “I always put spaces in the wrong place, now I don't have to worry about it +* “I always put spaces in the wrong place, now I don't have to worry about it anymore.” -- “When you're a beginner you're making a lot of mistakes caused by the syntax. +* “When you're a beginner you're making a lot of mistakes caused by the syntax. Thanks to Prettier, you can reduce these mistakes and save a lot of time to focus on what really matters.” -- “As a teacher, I will also tell to my students to install Prettier to help +* “As a teacher, I will also tell to my students to install Prettier to help them to learn the JS syntax and have readable files.” ### Writing code @@ -1087,9 +1087,9 @@ they actually spend a lot of time and mental energy formatting their code. With Prettier editor integration, you can just press that magic key binding and poof, the code is formatted. This is an eye opening experience if anything else. -- “I want to write code. Not spend cycles on formatting.” -- “It removed 5% that sucks in our daily life - aka formatting” -- “We're in 2017 and it's still painful to break a call into multiple lines when +* “I want to write code. Not spend cycles on formatting.” +* “It removed 5% that sucks in our daily life - aka formatting” +* “We're in 2017 and it's still painful to break a call into multiple lines when you happen to add an argument that makes it go over the 80 columns limit :(“ ### Easy to adopt @@ -1101,16 +1101,16 @@ only should it be painless for you to do it technically but the newly formatted codebase should not generate major controversy and be accepted painlessly by your co-workers. -- “It's low overhead. We were able to throw Prettier at very different kinds of +* “It's low overhead. We were able to throw Prettier at very different kinds of repos without much work.” -- “It's been mostly bug free. Had there been major styling issues during the +* “It's been mostly bug free. Had there been major styling issues during the course of implementation we would have been wary about throwing this at our JS codebase. I'm happy to say that's not the case.” -- “Everyone runs it as part of their pre commit scripts, a couple of us use the +* “Everyone runs it as part of their pre commit scripts, a couple of us use the editor on save extensions as well.” -- “It's fast, against one of our larger JS codebases we were able to run +* “It's fast, against one of our larger JS codebases we were able to run Prettier in under 13 seconds.” -- “The biggest benefit for Prettier for us was being able to format the entire +* “The biggest benefit for Prettier for us was being able to format the entire code base at once.” ### Clean up an existing codebase @@ -1120,8 +1120,8 @@ often slips through the cracks and you are left working on inconsistent codebases. Running Prettier in this case is a quick win, the codebase is now uniform and easier to read without spending hardly any time. -- “Take a look at the code :) I just need to restore sanity.” -- “We inherited a ~2000 module ES6 code base, developed by 20 different +* “Take a look at the code :) I just need to restore sanity.” +* “We inherited a ~2000 module ES6 code base, developed by 20 different developers over 18 months, in a global team. Felt like such a win without much research.” @@ -1131,11 +1131,11 @@ Purely technical aspects of the projects aren't the only thing people look into when choosing to adopt Prettier. Who built and uses it and how quickly it spreads through the community has a non-trivial impact. -- “The amazing thing, for me, is: 1) Announced 2 months ago. 2) Already adopted +* “The amazing thing, for me, is: 1) Announced 2 months ago. 2) Already adopted by, it seems, every major JS project. 3) 7000 stars, 100,000 npm downloads/mo” -- “Was built by the same people as React & React Native.” -- “I like to be part of the hot new things.” -- “Because soon enough people are gonna ask for it.” +* “Was built by the same people as React & React Native.” +* “I like to be part of the hot new things.” +* “Because soon enough people are gonna ask for it.” A few of the [many projects](https://www.npmjs.com/browse/depended/prettier) using Prettier: @@ -1467,8 +1467,8 @@ The function optionally accepts an input file path as an argument, which defaults to the current working directory. A promise is returned which will resolve to: -- An options object, providing a [config file](#configuration-file) was found. -- \`null\`, if no file was found. +* An options object, providing a [config file](#configuration-file) was found. +* \`null\`, if no file was found. The promise will be rejected if there was an error parsing the configuration file. @@ -1596,8 +1596,8 @@ Print semicolons at the ends of statements. Valid options: -- \`true\` - Add a semicolon at the end of every statement. -- \`false\` - Only add semicolons at the beginning of lines that may introduce ASI +* \`true\` - Add a semicolon at the end of every statement. +* \`false\` - Only add semicolons at the beginning of lines that may introduce ASI failures. | Default | CLI Override | API Override | @@ -1610,8 +1610,8 @@ Use single quotes instead of double quotes. Notes: -- Quotes in JSX will always be double and ignore this setting. -- If the number of quotes outweighs the other quote, the quote which is less +* Quotes in JSX will always be double and ignore this setting. +* If the number of quotes outweighs the other quote, the quote which is less used will be used to format the string - Example: \`"I'm double quoted"\` results in \`"I'm double quoted"\` and \`"This \\"example\\" is single quoted"\` results in \`'This "example" is single quoted'\`. @@ -1627,9 +1627,9 @@ for example, never gets trailing commas.) Valid options: -- \`"none"\` - No trailing commas. -- \`"es5"\` - Trailing commas where valid in ES5 (objects, arrays, etc.) -- \`"all"\` - Trailing commas wherever possible (including function arguments). +* \`"none"\` - No trailing commas. +* \`"es5"\` - Trailing commas where valid in ES5 (objects, arrays, etc.) +* \`"all"\` - Trailing commas wherever possible (including function arguments). This requires node 8 or a [transform](https://babeljs.io/docs/plugins/syntax-trailing-function-commas/). @@ -1643,8 +1643,8 @@ Print spaces between brackets in object literals. Valid options: -- \`true\` - Example: \`{ foo: bar }\`. -- \`false\` - Example: \`{foo: bar}\`. +* \`true\` - Example: \`{ foo: bar }\`. +* \`false\` - Example: \`{foo: bar}\`. | Default | CLI Override | API Override | | ------- | ---------------------- | ------------------------ | @@ -1666,8 +1666,8 @@ Format only a segment of a file. These two options can be used to format code starting and ending at a given character offset (inclusive and exclusive, respectively). The range will extend: -- Backwards to the start of the first line containing the selected statement. -- Forwards to the end of the selected statement. +* Backwards to the start of the first line containing the selected statement. +* Forwards to the end of the selected statement. These options cannot be used with \`cursorOffset\`. @@ -1686,14 +1686,14 @@ input file path, so you shouldn't have to change this setting. Built-in parsers: -- [\`babylon\`](https://github.com/babel/babylon/) -- [\`flow\`](https://github.com/facebook/flow/tree/master/src/parser) -- [\`typescript\`](https://github.com/eslint/typescript-eslint-parser) _Since +* [\`babylon\`](https://github.com/babel/babylon/) +* [\`flow\`](https://github.com/facebook/flow/tree/master/src/parser) +* [\`typescript\`](https://github.com/eslint/typescript-eslint-parser) _Since v1.4.0_ -- [\`postcss\`](https://github.com/postcss/postcss) _Since v1.4.0_ -- [\`json\`](https://github.com/babel/babylon/tree/f09eb3200f57ea94d51c2a5b1facf2149fb406bf#babylonparseexpressioncode-options) +* [\`postcss\`](https://github.com/postcss/postcss) _Since v1.4.0_ +* [\`json\`](https://github.com/babel/babylon/tree/f09eb3200f57ea94d51c2a5b1facf2149fb406bf#babylonparseexpressioncode-options) _Since v1.5.0_ -- [\`graphql\`](https://github.com/graphql/graphql-js/tree/master/src/language) +* [\`graphql\`](https://github.com/graphql/graphql-js/tree/master/src/language) _Since v1.5.0_ [Custom parsers](#custom-parser-api) are also supported. _Since v1.5.0_ @@ -1748,10 +1748,10 @@ or Prettier uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for configuration file support. This means you can configure prettier via: -- A \`.prettierrc\` file, written in YAML or JSON, with optional extensions: +* A \`.prettierrc\` file, written in YAML or JSON, with optional extensions: \`.yaml/.yml/.json/.js\`. -- A \`prettier.config.js\` file that exports an object. -- A \`"prettier"\` key in your \`package.json\` file. +* A \`prettier.config.js\` file that exports an object. +* A \`"prettier"\` key in your \`package.json\` file. The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a config file is (or @@ -1905,42 +1905,42 @@ ability to have leading \`|\` for type definitions which prettier outputs. ## Related Projects -- [\`eslint-plugin-prettier\`](https://github.com/prettier/eslint-plugin-prettier) +* [\`eslint-plugin-prettier\`](https://github.com/prettier/eslint-plugin-prettier) plugs Prettier into your ESLint workflow -- [\`eslint-config-prettier\`](https://github.com/prettier/eslint-config-prettier) +* [\`eslint-config-prettier\`](https://github.com/prettier/eslint-config-prettier) turns off all ESLint rules that are unnecessary or might conflict with Prettier -- [\`prettier-eslint\`](https://github.com/prettier/prettier-eslint) passes +* [\`prettier-eslint\`](https://github.com/prettier/prettier-eslint) passes \`prettier\` output to \`eslint --fix\` -- [\`prettier-stylelint\`](https://github.com/hugomrdias/prettier-stylelint) +* [\`prettier-stylelint\`](https://github.com/hugomrdias/prettier-stylelint) passes \`prettier\` output to \`stylelint --fix\` -- [\`prettier-standard\`](https://github.com/sheerun/prettier-standard) uses +* [\`prettier-standard\`](https://github.com/sheerun/prettier-standard) uses \`prettier\` and \`prettier-eslint\` to format code with standard rules -- [\`prettier-standard-formatter\`](https://github.com/dtinth/prettier-standard-formatter) +* [\`prettier-standard-formatter\`](https://github.com/dtinth/prettier-standard-formatter) passes \`prettier\` output to \`standard --fix\` -- [\`prettier-miscellaneous\`](https://github.com/arijs/prettier-miscellaneous) +* [\`prettier-miscellaneous\`](https://github.com/arijs/prettier-miscellaneous) \`prettier\` with a few minor extra options -- [\`neutrino-preset-prettier\`](https://github.com/SpencerCDixon/neutrino-preset-prettier) +* [\`neutrino-preset-prettier\`](https://github.com/SpencerCDixon/neutrino-preset-prettier) allows you to use Prettier as a Neutrino preset -- [\`prettier_d\`](https://github.com/josephfrazier/prettier_d.js) runs Prettier +* [\`prettier_d\`](https://github.com/josephfrazier/prettier_d.js) runs Prettier as a server to avoid Node.js startup delay. It also supports configuration via \`.prettierrc\`, \`package.json\`, and \`.editorconfig\`. -- [\`Prettier Bookmarklet\`](https://prettier.glitch.me/) provides a bookmarklet +* [\`Prettier Bookmarklet\`](https://prettier.glitch.me/) provides a bookmarklet and exposes a REST API for Prettier that allows to format CodeMirror editor in your browser -- [\`prettier-github\`](https://github.com/jgierer12/prettier-github) formats code +* [\`prettier-github\`](https://github.com/jgierer12/prettier-github) formats code in GitHub comments -- [\`rollup-plugin-prettier\`](https://github.com/mjeanroy/rollup-plugin-prettier) +* [\`rollup-plugin-prettier\`](https://github.com/mjeanroy/rollup-plugin-prettier) allows you to use Prettier with Rollup -- [\`markdown-magic-prettier\`](https://github.com/camacho/markdown-magic-prettier) +* [\`markdown-magic-prettier\`](https://github.com/camacho/markdown-magic-prettier) allows you to use Prettier to format JS [codeblocks](https://help.github.com/articles/creating-and-highlighting-code-blocks/) in Markdown files via [Markdown Magic](https://github.com/DavidWells/markdown-magic) -- [\`tslint-plugin-prettier\`](https://github.com/ikatyang/tslint-plugin-prettier) +* [\`tslint-plugin-prettier\`](https://github.com/ikatyang/tslint-plugin-prettier) runs Prettier as a TSLint rule and reports differences as individual TSLint issues -- [\`tslint-config-prettier\`](https://github.com/alexjoverm/tslint-config-prettier) +* [\`tslint-config-prettier\`](https://github.com/alexjoverm/tslint-config-prettier) use TSLint with Prettier without any conflict ## Technical Details @@ -2259,30 +2259,30 @@ This is a paragraph. > > Markdown.generate(); -- Red -- Green -- Blue - -+ Red -+ Green -+ Blue +* Red +* Green +* Blue - Red - Green - Blue +* Red +* Green +* Blue + \`\`\`markdown -- Red -- Green -- Blue - -+ Red -+ Green -+ Blue +* Red +* Green +* Blue - Red - Green - Blue + +* Red +* Green +* Blue \`\`\` 1. Buy flour and salt diff --git a/tests/markdown_code/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_code/__snapshots__/jsfmt.spec.js.snap index 54469a28..93374142 100644 --- a/tests/markdown_code/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_code/__snapshots__/jsfmt.spec.js.snap @@ -55,7 +55,7 @@ exports[`indent.md 1`] = ` Indented Code Block Indented Code Block -- \`\`\` +* \`\`\` Fenced Code Block Fenced Code Block Fenced Code Block diff --git a/tests/markdown_ignore/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_ignore/__snapshots__/jsfmt.spec.js.snap index b73ff02e..6f30d6c7 100644 --- a/tests/markdown_ignore/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_ignore/__snapshots__/jsfmt.spec.js.snap @@ -9,9 +9,9 @@ exports[`indented.md 1`] = ` long long long long long long paragraph. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 123 -- 456 -- 789 +* 123 +* 456 +* 789 - This is a long long long long long long diff --git a/tests/markdown_list/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_list/__snapshots__/jsfmt.spec.js.snap index 68de59cc..269b242d 100644 --- a/tests/markdown_list/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_list/__snapshots__/jsfmt.spec.js.snap @@ -4,9 +4,9 @@ exports[`checkbox.md 1`] = ` - [ ] this is a long long long long long long long long long long long long long long paragraph. - [x] this is a long long long long long long long long long long long long long long paragraph. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- [ ] this is a long long long long long long long long long long long long long +* [ ] this is a long long long long long long long long long long long long long long paragraph. -- [x] this is a long long long long long long long long long long long long long +* [x] this is a long long long long long long long long long long long long long long paragraph. `; @@ -14,7 +14,7 @@ exports[`checkbox.md 1`] = ` exports[`long-paragraph.md 1`] = ` - This is a long long long long long long long long long long long long long long paragraph. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- This is a long long long long long long long long long long long long long +* This is a long long long long long long long long long long long long long long paragraph. `; @@ -32,17 +32,17 @@ exports[`loose.md 1`] = ` - ghi ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 123 +* 123 - - abc + * abc -- 456 +* 456 - - def + * def -- 789 +* 789 - - ghi + * ghi `; @@ -51,7 +51,7 @@ exports[`multiline.md 1`] = ` 456 789 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 123 456 789 +* 123 456 789 `; @@ -60,9 +60,9 @@ exports[`nested.md 1`] = ` - Level 2 - Level 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Level 1 - - Level 2 - - Level 3 +* Level 1 + * Level 2 + * Level 3 `; @@ -86,13 +86,13 @@ exports[`separate.md 1`] = ` * 123 * 123 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 123 -- 123 -- 123 +* 123 +* 123 +* 123 -+ 123 -+ 123 -+ 123 +- 123 +- 123 +- 123 `; @@ -101,9 +101,9 @@ exports[`simple.md 1`] = ` - 456 - 789 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 123 -- 456 -- 789 +* 123 +* 456 +* 789 `; diff --git a/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap index 71fa8437..f50a52d0 100644 --- a/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap @@ -28,7 +28,7 @@ exports[`example-4.md 1`] = ` bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo bar @@ -39,7 +39,7 @@ exports[`example-5.md 1`] = ` bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo bar @@ -55,7 +55,7 @@ exports[`example-6.md 1`] = ` exports[`example-7.md 1`] = ` - foo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo `; @@ -73,8 +73,8 @@ exports[`example-9.md 1`] = ` - bar - baz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo - - bar - baz +* foo + * bar - baz `; @@ -82,8 +82,8 @@ exports[`example-10.md 1`] = ` - \`one - two\` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- \`one -- two\` +* \`one +* two\` `; @@ -206,11 +206,11 @@ exports[`example-25.md 1`] = ` *** - bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo - - - -- bar +* bar `; @@ -243,11 +243,11 @@ exports[`example-28.md 1`] = ` * * * * Bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Foo +* Foo - - - -- Bar +* Bar `; @@ -255,8 +255,8 @@ exports[`example-29.md 1`] = ` - Foo - * * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Foo -- * * * +* Foo +* - - - `; @@ -611,7 +611,7 @@ exports[`example-62.md 1`] = ` - Foo --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Foo +* Foo - - - @@ -668,7 +668,7 @@ exports[`example-67.md 1`] = ` - foo ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo - - - @@ -771,7 +771,7 @@ exports[`example-76.md 1`] = ` bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo bar @@ -784,7 +784,7 @@ exports[`example-77.md 1`] = ` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. foo - - bar + * bar `; @@ -1530,8 +1530,8 @@ exports[`example-139.md 1`] = ` -
- foo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --
-- foo +*
+* foo `; @@ -2199,9 +2199,9 @@ exports[`example-195.md 1`] = ` > - foo - bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -> - foo +> * foo -- bar +* bar `; @@ -2413,7 +2413,7 @@ exports[`example-215.md 1`] = ` two ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- one +* one two @@ -2424,7 +2424,7 @@ exports[`example-216.md 1`] = ` two ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- one +* one two @@ -2435,7 +2435,7 @@ exports[`example-217.md 1`] = ` two ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- one +* one two @@ -2446,7 +2446,7 @@ exports[`example-218.md 1`] = ` two ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- one +* one two @@ -2468,7 +2468,7 @@ exports[`example-220.md 1`] = ` >> > > two ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -> > - one +> > * one > > > > two @@ -2511,15 +2511,15 @@ exports[`example-222.md 1`] = ` bar \`\`\` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo bar -- foo +* foo bar -- \`\`\` +* \`\`\` foo \`\`\` @@ -2566,7 +2566,7 @@ exports[`example-224.md 1`] = ` baz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Foo +* Foo bar @@ -2582,7 +2582,7 @@ exports[`example-225.md 1`] = ` baz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Foo +* Foo bar @@ -2631,7 +2631,7 @@ exports[`example-231.md 1`] = ` bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo bar @@ -2709,7 +2709,7 @@ exports[`example-237.md 1`] = ` bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo bar @@ -2720,7 +2720,7 @@ exports[`example-238.md 1`] = ` bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo bar @@ -2742,9 +2742,9 @@ exports[`example-241.md 1`] = ` - - bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo -- -- bar +* foo +* +* bar `; @@ -2753,9 +2753,9 @@ exports[`example-242.md 1`] = ` - - bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo -- -- bar +* foo +* +* bar `; @@ -2887,9 +2887,9 @@ exports[`example-253.md 1`] = ` - bar - baz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo - - bar - - baz +* foo + * bar + * baz `; @@ -2898,9 +2898,9 @@ exports[`example-254.md 1`] = ` - bar - baz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo -- bar -- baz +* foo +* bar +* baz `; @@ -2909,7 +2909,7 @@ exports[`example-255.md 1`] = ` - bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10. foo - - bar + * bar `; @@ -2919,21 +2919,21 @@ exports[`example-256.md 1`] = ` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10. foo -- bar +* bar `; exports[`example-257.md 1`] = ` - - foo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- - foo +* * foo `; exports[`example-258.md 1`] = ` 1. - 2. foo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -1. - 2. foo +1. * 2. foo `; @@ -2943,8 +2943,8 @@ exports[`example-259.md 1`] = ` --- baz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- # Foo -- ## Bar +* # Foo +* ## Bar baz `; @@ -2954,10 +2954,10 @@ exports[`example-260.md 1`] = ` - bar + baz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo -- bar +* foo +* bar -+ baz +- baz `; @@ -2980,8 +2980,8 @@ Foo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Foo -- bar -- baz +* bar +* baz `; @@ -3003,11 +3003,11 @@ exports[`example-264.md 1`] = ` - baz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo -- bar +* bar -+ baz +- baz `; @@ -3018,11 +3018,11 @@ exports[`example-265.md 1`] = ` bar - baz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo bar -- baz +* baz `; @@ -3034,9 +3034,9 @@ exports[`example-266.md 1`] = ` bim ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo - - bar - - baz +* foo + * bar + * baz bim @@ -3051,11 +3051,11 @@ exports[`example-267.md 1`] = ` - baz - bim ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo -- bar +* foo +* bar -+ baz -+ bim +- baz +- bim `; @@ -3069,11 +3069,11 @@ exports[`example-268.md 1`] = ` code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo notcode -- foo +* foo code @@ -3091,15 +3091,15 @@ exports[`example-269.md 1`] = ` - h - i ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- a -- b -- c -- d - - e -- f -- g -- h -- i +* a +* b +* c +* d + * e +* f +* g +* h +* i `; @@ -3109,10 +3109,10 @@ exports[`example-271.md 1`] = ` - c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- a -- b +* a +* b -- c +* c `; @@ -3122,10 +3122,10 @@ exports[`example-272.md 1`] = ` * c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- a -- +* a +* -+ c +- c `; @@ -3136,12 +3136,12 @@ exports[`example-273.md 1`] = ` c - d ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- a -- b +* a +* b c -- d +* d `; @@ -3152,12 +3152,12 @@ exports[`example-274.md 1`] = ` [ref]: /url - d ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- a -- b +* a +* b [ref]: /url -- d +* d `; @@ -3168,13 +3168,13 @@ exports[`example-276.md 1`] = ` c - d ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- a +* a - - b + * b c -- d +* d `; @@ -3184,9 +3184,9 @@ exports[`example-277.md 1`] = ` > * c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- a +* a > b -- c +* c `; @@ -3198,19 +3198,19 @@ exports[`example-278.md 1`] = ` \`\`\` - d ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- a +* a > b \`\`\` c \`\`\` -- d +* d `; exports[`example-279.md 1`] = ` - a ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- a +* a `; @@ -3218,8 +3218,8 @@ exports[`example-280.md 1`] = ` - a - b ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- a - - b +* a + * b `; @@ -3244,9 +3244,9 @@ exports[`example-282.md 1`] = ` baz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- foo +* foo - - bar + * bar baz @@ -3261,14 +3261,14 @@ exports[`example-283.md 1`] = ` - e - f ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- a +* a - - b - - c + * b + * c -- d - - e - - f +* d + * e + * f `; diff --git a/tests/markdown_thematicBreak/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_thematicBreak/__snapshots__/jsfmt.spec.js.snap index a64ccf70..43f145f1 100644 --- a/tests/markdown_thematicBreak/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_thematicBreak/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`list.md 1`] = ` +- * * * ++ - - - +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* - - - + +- * * * + +`; + exports[`simple.md 1`] = ` *** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/markdown_thematicBreak/list.md b/tests/markdown_thematicBreak/list.md new file mode 100644 index 00000000..0581c796 --- /dev/null +++ b/tests/markdown_thematicBreak/list.md @@ -0,0 +1,2 @@ +- * * * ++ - - - diff --git a/tests/multiparser_js_markdown/__snapshots__/jsfmt.spec.js.snap b/tests/multiparser_js_markdown/__snapshots__/jsfmt.spec.js.snap index a17e887c..0726156f 100644 --- a/tests/multiparser_js_markdown/__snapshots__/jsfmt.spec.js.snap +++ b/tests/multiparser_js_markdown/__snapshots__/jsfmt.spec.js.snap @@ -55,21 +55,21 @@ export default function ReadMe() { and unrewarding process. People get very emotional around particular ways of writing code and nobody likes spending time writing and receiving nits. - - “We want to free mental threads and end discussions around style. While + * “We want to free mental threads and end discussions around style. While sometimes fruitful, these discussions are for the most part wasteful.” - - “Literally had an engineer go through a huge effort of cleaning up all of + * “Literally had an engineer go through a huge effort of cleaning up all of our code because we were debating ternary style for the longest time and were inconsistent about it. It was dumb, but it was a weird on-going "great debate" that wasted lots of little back and forth bits. It's far easier for us all to agree now: just run Prettier, and go with that style.” - - “Getting tired telling people how to style their product code.” - - “Our top reason was to stop wasting our time debating style nits.” - - “Having a githook set up has reduced the amount of style issues in PRs + * “Getting tired telling people how to style their product code.” + * “Our top reason was to stop wasting our time debating style nits.” + * “Having a githook set up has reduced the amount of style issues in PRs that result in broken builds due to ESLint rules or things I have to nit-pick or clean up later.” - - “I don't want anybody to nitpick any other person ever again.” - - “It reminds me of how Steve Jobs used to wear the same clothes every day + * “I don't want anybody to nitpick any other person ever again.” + * “It reminds me of how Steve Jobs used to wear the same clothes every day because he has a million decisions to make and he didn't want to be bothered to make trivial ones like picking out clothes. I think Prettier is like that.”