Skip to content

Commit

Permalink
fix(markdown): preserve inline math style (prettier#5220)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang authored Oct 10, 2018
1 parent b5fd382 commit bb5a116
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/language-markdown/printer-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,15 @@ function genericPrint(path, options, print) {
: "",
"$$"
]);
case "inlineMath":
return concat(["$", node.value, "$"]);
case "inlineMath": {
// $$math$$ can be block math in some variants
// see https://github.com/Rokt33r/remark-math#double-dollars-in-inline
const style =
options.originalText[node.position.start.offset + 1] === "$"
? "$$"
: "$";
return concat([style, node.value, style]);
}

case "tableRow": // handled in "table"
case "listItem": // handled in "list"
Expand Down
4 changes: 2 additions & 2 deletions tests/markdown_math/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ $$
---
$\\\\alpha$
$$\\\\alpha$$
---
$\\alpha$
$$\\alpha$$
$$
\\alpha\\beta
Expand Down

0 comments on commit bb5a116

Please sign in to comment.