fix(markdown): do not trim content in inline-math (#5485)

master
Ika 2018-11-16 00:17:20 +08:00 committed by GitHub
parent e588533e16
commit 043a937de6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 7 deletions

View File

@ -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"

View File

@ -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 -->

View File

@ -0,0 +1 @@
$10 - $20