fix(markdown): do not trim content in inline-math (#5485)
parent
e588533e16
commit
043a937de6
|
@ -409,13 +409,12 @@ function genericPrint(path, options, print) {
|
|||
"$$"
|
||||
]);
|
||||
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]);
|
||||
// remark-math trims content but we don't want to remove whitespaces
|
||||
// since it's very possible that it's recognized as math accidentally
|
||||
return options.originalText.slice(
|
||||
options.locStart(node),
|
||||
options.locEnd(node)
|
||||
);
|
||||
}
|
||||
|
||||
case "tableRow": // handled in "table"
|
||||
|
|
|
@ -28,6 +28,13 @@ $$
|
|||
|
||||
`;
|
||||
|
||||
exports[`math-like.md - markdown-verify 1`] = `
|
||||
$10 - $20
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
$10 - $20
|
||||
|
||||
`;
|
||||
|
||||
exports[`remark-math.md - markdown-verify 1`] = `
|
||||
<!-- tests from https://github.com/Rokt33r/remark-math/blob/9e13e49/specs/remark-math.spec.js -->
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$10 - $20
|
Loading…
Reference in New Issue