From 20994d73517ae696d96bc5556ee3e11a4a6dad20 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Mon, 16 Dec 2013 05:46:04 -0800 Subject: [PATCH] Prevent line breaks immediately after math For whatever reason, `,` allows a break in between the block and the comma. `,` doesn't. Auditors: emily --- buildTree.js | 4 +++- static/katex.less | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/buildTree.js b/buildTree.js index 1c99c9b41..92d631e3c 100644 --- a/buildTree.js +++ b/buildTree.js @@ -535,7 +535,9 @@ var buildTree = function(tree) { topStrut.style.height = span.height + "em"; bottomStrut.style.height = (span.height + span.depth) + "em"; - var katexNode = makeSpan(["katex"], [topStrut, bottomStrut, span]); + var katexNode = makeSpan(["katex"], [ + makeSpan(["katex-inner"], [topStrut, bottomStrut, span]) + ]); return katexNode.toDOM(); }; diff --git a/static/katex.less b/static/katex.less index 9cf742a16..260980150 100644 --- a/static/katex.less +++ b/static/katex.less @@ -6,11 +6,17 @@ big parens */ .katex { - display: inline-block; font: normal 1.21em katex_main; line-height: 1.2; white-space: nowrap; + .katex-inner { + // Making .katex inline-block allows line breaks before and after, + // which is undesireable ("to $x$,"). Instead, adjust the .katex-inner + // style and put nowrap on the inline .katex element. + display: inline-block; + } + .base { display: inline-block; }