diff --git a/docs/options.md b/docs/options.md index c05ed26a0..4e70672b8 100644 --- a/docs/options.md +++ b/docs/options.md @@ -205,8 +205,14 @@ Prettier can insert a special @format marker at the top of files specifying that _available in v1.8.2+_ -By default, Prettier will wrap markdown text at the specified print width. In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out. When prose wrapping is disabled, each paragraph will be printed on its own line. +By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer, e.g. GitHub comment and BitBucket. In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out with `"never"`. -| Default | CLI Override | API Override | -| ------- | ----------------- | ------------------- | -| `true` | `--no-prose-wrap` | `proseWrap: ` | +Valid options: + +* `"always"` - Wrap prose if it exceeds the print width. +* `"never"` - Do not wrap prose. +* `"preserve"` - Wrap prose as-is. _available in v1.9.0+_ + +| Default | CLI Override | API Override | +| ------------ | ----------------------------------------------------------- | ----------------------------------------------------------- | +| `"preserve"` | --prose-wrap | proseWrap: "" | diff --git a/src/clean-ast.js b/src/clean-ast.js index 8608b46bc..d85c11bbc 100644 --- a/src/clean-ast.js +++ b/src/clean-ast.js @@ -63,6 +63,10 @@ function massageAST(ast, parent) { if (ast.type === "code") { delete newObj.value; } + // for markdown whitespace: "\n" and " " are considered the same + if (ast.type === "whitespace" && ast.value === "\n") { + newObj.value = " "; + } if ( ast.type === "media-query" || diff --git a/src/cli-constant.js b/src/cli-constant.js index 018540694..829d1dd07 100644 --- a/src/cli-constant.js +++ b/src/cli-constant.js @@ -237,11 +237,19 @@ const detailedOptions = normalizeDetailedOptions({ description: "The line length where Prettier will try wrap." }, "prose-wrap": { - type: "boolean", + type: "choice", category: CATEGORY_FORMAT, forwardToApi: true, - description: "Wrap prose if it exceeds the print width. (markdown)", - oppositeDescription: "Do not wrap prose. (markdown)" + description: "How to wrap prose. (markdown)", + choices: [ + { + value: "always", + description: "Wrap prose if it exceeds the print width." + }, + { value: "never", description: "Do not wrap prose." }, + { value: "preserve", description: "Wrap prose as-is." }, + { value: false, deprecated: true, redirect: "never" } + ] }, "range-end": { type: "int", diff --git a/src/options.js b/src/options.js index f0d963157..d166a3b2d 100644 --- a/src/options.js +++ b/src/options.js @@ -21,7 +21,7 @@ const defaults = { insertPragma: false, requirePragma: false, semi: true, - proseWrap: true, + proseWrap: "preserve", arrowParens: "avoid" }; @@ -72,6 +72,16 @@ function normalize(options) { ); } + /* istanbul ignore if */ + if (typeof normalized.proseWrap === "boolean") { + normalized.proseWrap = normalized.proseWrap ? "always" : "never"; + + console.warn( + "Warning: `proseWrap` with boolean value is deprecated. " + + 'Use "always", "never", or "preserve" instead.' + ); + } + /* istanbul ignore if */ if (normalized.parser === "postcss") { normalized.parser = "css"; diff --git a/src/printer-markdown.js b/src/printer-markdown.js index 8eeab6406..eeca4d7ba 100644 --- a/src/printer-markdown.js +++ b/src/printer-markdown.js @@ -60,7 +60,7 @@ function genericPrint(path, options, print) { node => node.type === "word" ? node.value - : node.value === "" ? "" : printLine(path, line, options) + : node.value === "" ? "" : printLine(path, node.value, options) ) ); } @@ -99,12 +99,13 @@ function genericPrint(path, options, print) { const index = parentNode.children.indexOf(node); const nextNode = parentNode.children[index + 1]; - // leading char that may cause different syntax - if (nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value)) { - return node.value === "" ? "" : " "; - } + const proseWrap = + // leading char that may cause different syntax + nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value) + ? "never" + : options.proseWrap; - return printLine(path, node.value === "" ? softline : line, options); + return printLine(path, node.value, { proseWrap }); } case "emphasis": { const parentNode = path.getParentNode(); @@ -367,10 +368,15 @@ function getAncestorNode(path, typeOrTypes) { return counter === -1 ? null : path.getParentNode(counter); } -function printLine(path, lineOrSoftline, options) { +function printLine(path, value, options) { + if (options.proseWrap === "preserve" && value === "\n") { + return hardline; + } + const isBreakable = - options.proseWrap && !getAncestorNode(path, SINGLE_LINE_NODE_TYPES); - return lineOrSoftline === line + options.proseWrap === "always" && + !getAncestorNode(path, SINGLE_LINE_NODE_TYPES); + return value !== "" ? isBreakable ? line : " " : isBreakable ? softline : ""; } diff --git a/src/util.js b/src/util.js index a4ec8f024..958bf3c14 100644 --- a/src/util.js +++ b/src/util.js @@ -672,7 +672,7 @@ function mapDoc(doc, callback) { /** * split text into whitespaces and words * @param {string} text - * @return {Array<{ type: "whitespace", value: " " | "" } | { type: "word", value: string }>} + * @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} */ function splitText(text) { const KIND_NON_CJK = "non-cjk"; @@ -687,7 +687,10 @@ function splitText(text) { .forEach((token, index, tokens) => { // whitespace if (index % 2 === 1) { - nodes.push({ type: "whitespace", value: " " }); + nodes.push({ + type: "whitespace", + value: /\n/.test(token) ? "\n" : " " + }); return; } diff --git a/tests/markdown/jsfmt.spec.js b/tests/markdown/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown/jsfmt.spec.js +++ b/tests/markdown/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_blockquote/jsfmt.spec.js b/tests/markdown_blockquote/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_blockquote/jsfmt.spec.js +++ b/tests/markdown_blockquote/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_break/jsfmt.spec.js b/tests/markdown_break/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_break/jsfmt.spec.js +++ b/tests/markdown_break/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_code/jsfmt.spec.js b/tests/markdown_code/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_code/jsfmt.spec.js +++ b/tests/markdown_code/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_definition/jsfmt.spec.js b/tests/markdown_definition/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_definition/jsfmt.spec.js +++ b/tests/markdown_definition/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_delete/jsfmt.spec.js b/tests/markdown_delete/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_delete/jsfmt.spec.js +++ b/tests/markdown_delete/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_emphasis/jsfmt.spec.js b/tests/markdown_emphasis/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_emphasis/jsfmt.spec.js +++ b/tests/markdown_emphasis/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_footnote/jsfmt.spec.js b/tests/markdown_footnote/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_footnote/jsfmt.spec.js +++ b/tests/markdown_footnote/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_footnoteDefinition/jsfmt.spec.js b/tests/markdown_footnoteDefinition/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_footnoteDefinition/jsfmt.spec.js +++ b/tests/markdown_footnoteDefinition/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_footnoteReference/jsfmt.spec.js b/tests/markdown_footnoteReference/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_footnoteReference/jsfmt.spec.js +++ b/tests/markdown_footnoteReference/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_heading/jsfmt.spec.js b/tests/markdown_heading/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_heading/jsfmt.spec.js +++ b/tests/markdown_heading/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_html/jsfmt.spec.js b/tests/markdown_html/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_html/jsfmt.spec.js +++ b/tests/markdown_html/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_ignore/jsfmt.spec.js b/tests/markdown_ignore/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_ignore/jsfmt.spec.js +++ b/tests/markdown_ignore/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_image/jsfmt.spec.js b/tests/markdown_image/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_image/jsfmt.spec.js +++ b/tests/markdown_image/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_imageReference/jsfmt.spec.js b/tests/markdown_imageReference/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_imageReference/jsfmt.spec.js +++ b/tests/markdown_imageReference/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_indentation/jsfmt.spec.js b/tests/markdown_indentation/jsfmt.spec.js index 1e32ad7dc..8183e3720 100644 --- a/tests/markdown_indentation/jsfmt.spec.js +++ b/tests/markdown_indentation/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"], { useTabs: true }); +run_spec(__dirname, ["markdown"], { proseWrap: "always", useTabs: true }); diff --git a/tests/markdown_inlineCode/jsfmt.spec.js b/tests/markdown_inlineCode/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_inlineCode/jsfmt.spec.js +++ b/tests/markdown_inlineCode/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_jsx_semi/jsfmt.spec.js b/tests/markdown_jsx_semi/jsfmt.spec.js index ed93ee51b..d3fad0705 100644 --- a/tests/markdown_jsx_semi/jsfmt.spec.js +++ b/tests/markdown_jsx_semi/jsfmt.spec.js @@ -1,2 +1,2 @@ -run_spec(__dirname, ["markdown"], { semi: true }); -run_spec(__dirname, ["markdown"], { semi: false }); +run_spec(__dirname, ["markdown"], { semi: true, proseWrap: "always" }); +run_spec(__dirname, ["markdown"], { semi: false, proseWrap: "always" }); diff --git a/tests/markdown_link/jsfmt.spec.js b/tests/markdown_link/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_link/jsfmt.spec.js +++ b/tests/markdown_link/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_linkReference/jsfmt.spec.js b/tests/markdown_linkReference/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_linkReference/jsfmt.spec.js +++ b/tests/markdown_linkReference/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_list/jsfmt.spec.js b/tests/markdown_list/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_list/jsfmt.spec.js +++ b/tests/markdown_list/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_paragraph/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_paragraph/__snapshots__/jsfmt.spec.js.snap index f815a6938..e7c8aaccc 100644 --- a/tests/markdown_paragraph/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_paragraph/__snapshots__/jsfmt.spec.js.snap @@ -65,6 +65,33 @@ This ia an english paragraph with a CJK quote “中文“. `; +exports[`cjk.md 3`] = ` +這是一段很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長的段落 + +這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph!這是一個English混合著中文的一段Paragraph! + +全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白 + +This ia an english paragraph with a CJK quote "中文". + +This ia an english paragraph with a CJK quote “中文“. + +扩展运算符(spread)是三个点(\`...\`)。 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +這是一段很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長很長的段落 + +這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph!這是一個 English 混合著中文的一段 Paragraph! + +全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白全  形 空白 + +This ia an english paragraph with a CJK quote "中文". + +This ia an english paragraph with a CJK quote “中文“. + +扩展运算符(spread)是三个点(\`...\`)。 + +`; + exports[`inline-nodes.md 1`] = ` It removes all original styling[*](#styling-footnote) and ensures that all outputted code conforms to a consistent style. (See this [blog post](http://jlongster.com/A-Prettier-Formatter)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -81,6 +108,84 @@ It removes all original styling[\\*](#styling-footnote) and ensures that all out `; +exports[`inline-nodes.md 3`] = ` +It removes all original styling[*](#styling-footnote) and ensures that all outputted code conforms to a consistent style. (See this [blog post](http://jlongster.com/A-Prettier-Formatter)) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It removes all original styling[\\*](#styling-footnote) and ensures that all outputted code conforms to a consistent style. (See this [blog post](http://jlongster.com/A-Prettier-Formatter)) + +`; + +exports[`lorem.md 1`] = ` +Hic dicta et recusandae incidunt. Reiciendis saepe voluptatem tempore rem aut. +Iusto sapiente impedit. Laudantium ut id non et aperiam ab. + +Sit minus architecto quas quibusdam sed ipsam aut eum. +Dolores tempora reiciendis magni blanditiis laborum aliquid rem corporis enim. Et consectetur quo sed excepturi soluta repudiandae commodi id. +Eum possimus optio distinctio incidunt quasi optio culpa accusamus. +Architecto esse ut aut autem ullam consequatur reiciendis aliquid dolorum. + +Et quam mollitia velit iste enim exercitationem nemo. +Hic dignissimos eos et. Eos eos consequatur. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Hic dicta et recusandae incidunt. Reiciendis saepe voluptatem tempore rem aut. +Iusto sapiente impedit. Laudantium ut id non et aperiam ab. + +Sit minus architecto quas quibusdam sed ipsam aut eum. Dolores tempora +reiciendis magni blanditiis laborum aliquid rem corporis enim. Et consectetur +quo sed excepturi soluta repudiandae commodi id. Eum possimus optio distinctio +incidunt quasi optio culpa accusamus. Architecto esse ut aut autem ullam +consequatur reiciendis aliquid dolorum. + +Et quam mollitia velit iste enim exercitationem nemo. Hic dignissimos eos et. +Eos eos consequatur. + +`; + +exports[`lorem.md 2`] = ` +Hic dicta et recusandae incidunt. Reiciendis saepe voluptatem tempore rem aut. +Iusto sapiente impedit. Laudantium ut id non et aperiam ab. + +Sit minus architecto quas quibusdam sed ipsam aut eum. +Dolores tempora reiciendis magni blanditiis laborum aliquid rem corporis enim. Et consectetur quo sed excepturi soluta repudiandae commodi id. +Eum possimus optio distinctio incidunt quasi optio culpa accusamus. +Architecto esse ut aut autem ullam consequatur reiciendis aliquid dolorum. + +Et quam mollitia velit iste enim exercitationem nemo. +Hic dignissimos eos et. Eos eos consequatur. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Hic dicta et recusandae incidunt. Reiciendis saepe voluptatem tempore rem aut. Iusto sapiente impedit. Laudantium ut id non et aperiam ab. + +Sit minus architecto quas quibusdam sed ipsam aut eum. Dolores tempora reiciendis magni blanditiis laborum aliquid rem corporis enim. Et consectetur quo sed excepturi soluta repudiandae commodi id. Eum possimus optio distinctio incidunt quasi optio culpa accusamus. Architecto esse ut aut autem ullam consequatur reiciendis aliquid dolorum. + +Et quam mollitia velit iste enim exercitationem nemo. Hic dignissimos eos et. Eos eos consequatur. + +`; + +exports[`lorem.md 3`] = ` +Hic dicta et recusandae incidunt. Reiciendis saepe voluptatem tempore rem aut. +Iusto sapiente impedit. Laudantium ut id non et aperiam ab. + +Sit minus architecto quas quibusdam sed ipsam aut eum. +Dolores tempora reiciendis magni blanditiis laborum aliquid rem corporis enim. Et consectetur quo sed excepturi soluta repudiandae commodi id. +Eum possimus optio distinctio incidunt quasi optio culpa accusamus. +Architecto esse ut aut autem ullam consequatur reiciendis aliquid dolorum. + +Et quam mollitia velit iste enim exercitationem nemo. +Hic dignissimos eos et. Eos eos consequatur. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Hic dicta et recusandae incidunt. Reiciendis saepe voluptatem tempore rem aut. +Iusto sapiente impedit. Laudantium ut id non et aperiam ab. + +Sit minus architecto quas quibusdam sed ipsam aut eum. +Dolores tempora reiciendis magni blanditiis laborum aliquid rem corporis enim. Et consectetur quo sed excepturi soluta repudiandae commodi id. +Eum possimus optio distinctio incidunt quasi optio culpa accusamus. +Architecto esse ut aut autem ullam consequatur reiciendis aliquid dolorum. + +Et quam mollitia velit iste enim exercitationem nemo. +Hic dignissimos eos et. Eos eos consequatur. + +`; + exports[`simple.md 1`] = ` This is a long long long long long long long long long long long long long long long paragraph. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -96,6 +201,13 @@ This is a long long long long long long long long long long long long long long `; +exports[`simple.md 3`] = ` +This is a long 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 long long paragraph. + +`; + exports[`special-prefix.md 1`] = ` abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc - abc abc abc @@ -195,6 +307,53 @@ She grew up in an isolated village in the 19th century and met her father aged 2 `; +exports[`special-prefix.md 3`] = ` +abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc - abc abc abc + +## Supported Rules + +- [no-disabled-tests](/packages/eslint-plugin-jest/docs/rules/no-disabled-tests.md) - disallow disabled tests. +- [no-focused-tests](/packages/eslint-plugin-jest/docs/rules/no-focused-tests.md) - disallow focused tests. +- [no-identical-title](/packages/eslint-plugin-jest/docs/rules/no-identical-title.md) - disallow identical titles. +- [valid-expect](/packages/eslint-plugin-jest/docs/rules/valid-expect.md) - ensure expect is called correctly. + +## Supported Rules + +* [no-disabled-tests](/packages/eslint-plugin-jest/docs/rules/no-disabled-tests.md) + - disallow disabled tests. +* [no-focused-tests](/packages/eslint-plugin-jest/docs/rules/no-focused-tests.md) + - disallow focused tests. +* [no-identical-title](/packages/eslint-plugin-jest/docs/rules/no-identical-title.md) + - disallow identical titles. +* [valid-expect](/packages/eslint-plugin-jest/docs/rules/valid-expect.md) - + ensure expect is called correctly. + +She grew up in an isolated village in the 19th century and met her father aged 29. Oh no, why are we in a numbered list now? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc - abc abc abc + +## Supported Rules + +* [no-disabled-tests](/packages/eslint-plugin-jest/docs/rules/no-disabled-tests.md) - disallow disabled tests. +* [no-focused-tests](/packages/eslint-plugin-jest/docs/rules/no-focused-tests.md) - disallow focused tests. +* [no-identical-title](/packages/eslint-plugin-jest/docs/rules/no-identical-title.md) - disallow identical titles. +* [valid-expect](/packages/eslint-plugin-jest/docs/rules/valid-expect.md) - ensure expect is called correctly. + +## Supported Rules + +* [no-disabled-tests](/packages/eslint-plugin-jest/docs/rules/no-disabled-tests.md) + * disallow disabled tests. +* [no-focused-tests](/packages/eslint-plugin-jest/docs/rules/no-focused-tests.md) + * disallow focused tests. +* [no-identical-title](/packages/eslint-plugin-jest/docs/rules/no-identical-title.md) + * disallow identical titles. +* [valid-expect](/packages/eslint-plugin-jest/docs/rules/valid-expect.md) - + ensure expect is called correctly. + +She grew up in an isolated village in the 19th century and met her father aged 29. Oh no, why are we in a numbered list now? + +`; + exports[`whitespace.md 1`] = ` @@ -233,3 +392,22 @@ keep these words together keep these words together keep these words  keep these words together keep these words together keep these words together keep these words together `; + +exports[`whitespace.md 3`] = ` + + +keep these words together keep these words together keep these words together keep these words together + + + +keep these words together keep these words together keep these words together keep these words together +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +keep these words together keep these words together keep these words together keep these words together + + + +keep these words together keep these words together keep these words together keep these words together + +`; diff --git a/tests/markdown_paragraph/jsfmt.spec.js b/tests/markdown_paragraph/jsfmt.spec.js index d46cbff39..d15893e61 100644 --- a/tests/markdown_paragraph/jsfmt.spec.js +++ b/tests/markdown_paragraph/jsfmt.spec.js @@ -1,2 +1,3 @@ -run_spec(__dirname, ["markdown"]); -run_spec(__dirname, ["markdown"], { proseWrap: false }); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); +run_spec(__dirname, ["markdown"], { proseWrap: "never" }); +run_spec(__dirname, ["markdown"], { proseWrap: "preserve" }); diff --git a/tests/markdown_paragraph/lorem.md b/tests/markdown_paragraph/lorem.md new file mode 100644 index 000000000..b9b87ad1f --- /dev/null +++ b/tests/markdown_paragraph/lorem.md @@ -0,0 +1,10 @@ +Hic dicta et recusandae incidunt. Reiciendis saepe voluptatem tempore rem aut. +Iusto sapiente impedit. Laudantium ut id non et aperiam ab. + +Sit minus architecto quas quibusdam sed ipsam aut eum. +Dolores tempora reiciendis magni blanditiis laborum aliquid rem corporis enim. Et consectetur quo sed excepturi soluta repudiandae commodi id. +Eum possimus optio distinctio incidunt quasi optio culpa accusamus. +Architecto esse ut aut autem ullam consequatur reiciendis aliquid dolorum. + +Et quam mollitia velit iste enim exercitationem nemo. +Hic dignissimos eos et. Eos eos consequatur. diff --git a/tests/markdown_spec/jsfmt.spec.js b/tests/markdown_spec/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_spec/jsfmt.spec.js +++ b/tests/markdown_spec/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_splitCjkText/jsfmt.spec.js b/tests/markdown_splitCjkText/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_splitCjkText/jsfmt.spec.js +++ b/tests/markdown_splitCjkText/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_strong/jsfmt.spec.js b/tests/markdown_strong/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_strong/jsfmt.spec.js +++ b/tests/markdown_strong/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_table/jsfmt.spec.js b/tests/markdown_table/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_table/jsfmt.spec.js +++ b/tests/markdown_table/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_thematicBreak/jsfmt.spec.js b/tests/markdown_thematicBreak/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_thematicBreak/jsfmt.spec.js +++ b/tests/markdown_thematicBreak/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_toml/jsfmt.spec.js b/tests/markdown_toml/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_toml/jsfmt.spec.js +++ b/tests/markdown_toml/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_word/jsfmt.spec.js b/tests/markdown_word/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_word/jsfmt.spec.js +++ b/tests/markdown_word/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/markdown_yaml/jsfmt.spec.js b/tests/markdown_yaml/jsfmt.spec.js index ff3b58b03..b62fc5842 100644 --- a/tests/markdown_yaml/jsfmt.spec.js +++ b/tests/markdown_yaml/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["markdown"]); +run_spec(__dirname, ["markdown"], { proseWrap: "always" }); diff --git a/tests/multiparser_js_markdown/jsfmt.spec.js b/tests/multiparser_js_markdown/jsfmt.spec.js index 968651cdb..eee701ac8 100644 --- a/tests/multiparser_js_markdown/jsfmt.spec.js +++ b/tests/multiparser_js_markdown/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["babylon"]); +run_spec(__dirname, ["babylon"], { proseWrap: "always" }); diff --git a/tests_integration/__tests__/__snapshots__/early-exit.js.snap b/tests_integration/__tests__/__snapshots__/early-exit.js.snap index 3eafa6651..bfde0835a 100644 --- a/tests_integration/__tests__/__snapshots__/early-exit.js.snap +++ b/tests_integration/__tests__/__snapshots__/early-exit.js.snap @@ -226,17 +226,6 @@ exports[`show detailed usage with --help no-config (stdout) 1`] = ` exports[`show detailed usage with --help no-config (write) 1`] = `Array []`; -exports[`show detailed usage with --help no-prose-wrap (stderr) 1`] = `""`; - -exports[`show detailed usage with --help no-prose-wrap (stdout) 1`] = ` -"--no-prose-wrap - - Do not wrap prose. (markdown) -" -`; - -exports[`show detailed usage with --help no-prose-wrap (write) 1`] = `Array []`; - exports[`show detailed usage with --help no-semi (stderr) 1`] = `""`; exports[`show detailed usage with --help no-semi (stdout) 1`] = ` @@ -289,11 +278,17 @@ exports[`show detailed usage with --help print-width (write) 1`] = `Array []`; exports[`show detailed usage with --help prose-wrap (stderr) 1`] = `""`; exports[`show detailed usage with --help prose-wrap (stdout) 1`] = ` -"--prose-wrap +"--prose-wrap - Wrap prose if it exceeds the print width. (markdown) + How to wrap prose. (markdown) -Default: true +Valid options: + + always Wrap prose if it exceeds the print width. + never Do not wrap prose. + preserve Wrap prose as-is. + +Default: preserve " `; @@ -506,7 +501,9 @@ Format options: Defaults to babylon. --print-width The line length where Prettier will try wrap. Defaults to 80. - --no-prose-wrap Do not wrap prose. (markdown) + --prose-wrap + How to wrap prose. (markdown) + Defaults to preserve. --no-semi Do not print semicolons, except at the beginning of lines which may need them. --single-quote Use single quotes instead of double quotes. Defaults to false. @@ -642,7 +639,9 @@ Format options: Defaults to babylon. --print-width The line length where Prettier will try wrap. Defaults to 80. - --no-prose-wrap Do not wrap prose. (markdown) + --prose-wrap + How to wrap prose. (markdown) + Defaults to preserve. --no-semi Do not print semicolons, except at the beginning of lines which may need them. --single-quote Use single quotes instead of double quotes. Defaults to false.