Skip to content

Commit

Permalink
Add new Markdown option 'breakDefinitions' - Closes prettier#3531
Browse files Browse the repository at this point in the history
Allows to select if Markdown definitions should be broken when
'proseWrap' is set to 'always'. This enables, for example, single line
reference links, which can prevent potential rendering issues.
  • Loading branch information
JavierJF committed Apr 12, 2024
1 parent 1264a4c commit 8dac259
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/language-markdown/options.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import commonOptions from "../common/common-options.evaluate.js";

const CATEGORY_MARKDOWN = "Markdown";

// format based on https://github.com/prettier/prettier/blob/main/src/main/core-options.evaluate.js
const options = {
proseWrap: commonOptions.proseWrap,
singleQuote: commonOptions.singleQuote,
breakDefinitions: {
category: CATEGORY_MARKDOWN,
type: "boolean",
default: true,
description:
"Whether or not 'proseWrap' takes effect over Markdown definitions.",
}
};

export default options;
4 changes: 3 additions & 1 deletion src/language-markdown/printer-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ function genericPrint(path, options, print) {
];
}
case "definition": {
const lineOrSpace = options.proseWrap === "always" ? line : " ";
const lineOrSpace =
options.proseWrap === "always" &&
options.breakDefinitions === true ? line : " ";
return group([
printLinkReference(node),
":",
Expand Down

0 comments on commit 8dac259

Please sign in to comment.