Fix incorrect wrap in sentence with linkReference (#16546)

This commit is contained in:
Seiya authored and GitHub committed 2024-08-10 00:27:47 +01:00
1 parent 139e8de3c4
commit e977d65b19
4 files changed
+57 -2

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
#### Fix incorrect wrap in sentence with linkReference (#16546 by @seiyab)
<!-- prettier-ignore -->
```md
<!-- Input (--prose-wrap=always) -->
This folder has [VHS] tape files to create gifs for the [Widget Showcase]. To run them, install VHS from main (the theme and screenshot commands are not yet released).
<!-- Prettier stable -->
This folder has [VHS] tape files to create gifs for the [Widget Showcase]. To run
them, install VHS from main (the theme and screenshot commands are not yet released).
<!-- Prettier main -->
This folder has [VHS] tape files to create gifs for the [Widget Showcase]. To
run them, install VHS from main (the theme and screenshot commands are not yet
released).
```
+8 -2
View File
@@ -48,7 +48,12 @@ function genericPrint(path, options, print) {
const { node } = path;
if (shouldRemainTheSameContent(path)) {
/** @type {Doc} */
/*
* We assume parts always meet following conditions:
* - parts.length is odd
* - odd (0-indexed) elements are line-like doc
*/
/** @type {Doc[]} */
const parts = [""];
const textsNodes = splitText(
options.originalText.slice(
@@ -66,7 +71,8 @@ function genericPrint(path, options, print) {
parts.push([parts.pop(), doc]);
continue;
}
parts.push(doc);
// In this path, doc is line. To meet the condition, we need additional element "".
parts.push(doc, "");
}
return fill(parts);
}
@@ -349,3 +349,35 @@ proseWrap: "never"
================================================================================
`;
exports[`wrap.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "always"
| printWidth
=====================================input======================================
This folder has [VHS] tape files to create gifs for the [Widget Showcase]. To run them, install VHS from main (the theme and screenshot commands are not yet released).
=====================================output=====================================
This folder has [VHS] tape files to create gifs for the [Widget Showcase]. To
run them, install VHS from main (the theme and screenshot commands are not yet
released).
================================================================================
`;
exports[`wrap.md - {"proseWrap":"never"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80
proseWrap: "never"
| printWidth
=====================================input======================================
This folder has [VHS] tape files to create gifs for the [Widget Showcase]. To run them, install VHS from main (the theme and screenshot commands are not yet released).
=====================================output=====================================
This folder has [VHS] tape files to create gifs for the [Widget Showcase]. To run them, install VHS from main (the theme and screenshot commands are not yet released).
================================================================================
`;
@@ -0,0 +1 @@
This folder has [VHS] tape files to create gifs for the [Widget Showcase]. To run them, install VHS from main (the theme and screenshot commands are not yet released).