Repository: Khan/KaTeX
Pull request #1145 (2018-02-06 01:03:35)

Add \nobreakspace

codecov[bot]: # [Codecov](https://codecov.io/gh/Khan/KaTeX/pull/1145?src=pr&el=h1) Report
> Merging [#1145](https://codecov.io/gh/Khan/KaTeX/pull/1145?src=pr&el=desc) into [master](https://codecov.io/gh/Khan/KaTeX/commit/f977c25d0d229f25f77ad6bc04aed925145038ed?src=pr&el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/Khan/KaTeX/pull/1145/graphs/tree.svg?width=650&height=150&token=vfDnj2P77o&src=pr)](https://codecov.io/gh/Khan/KaTeX/pull/1145?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #1145      +/-   ##
==========================================
+ Coverage   78.94%   78.95%   +0.01%     
==========================================
  Files          59       59              
  Lines        3870     3872       +2     
  Branches      655      655              
==========================================
+ Hits         3055     3057       +2     
  Misses        674      674              
  Partials      141      141
```


| [Impacted Files](https://codecov.io/gh/Khan/KaTeX/pull/1145?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/symbols.js](https://codecov.io/gh/Khan/KaTeX/pull/1145/diff?src=pr&el=tree#diff-c3JjL3N5bWJvbHMuanM=) | `100% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Khan/KaTeX/pull/1145?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Khan/KaTeX/pull/1145?src=pr&el=footer). Last update [f977c25...ce39952](https://codecov.io/gh/Khan/KaTeX/pull/1145?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

ronkok: > Do we want a Unicode mapping for one of these

Maybe not. One can already get a non-breaking space using `~`. Also, `unicode-math-table.txt` contains no alias for U+00A0.

Patch:
diff --git a/src/symbols.js b/src/symbols.js
index 7572aded..8c498fdc 100644
--- a/src/symbols.js
+++ b/src/symbols.js
@@ -563,6 +563,8 @@ defineSymbol(math, main, spacing, null, "\\enspace");
 defineSymbol(math, main, spacing, null, "\\qquad");
 defineSymbol(math, main, spacing, null, "\\quad");
 defineSymbol(math, main, spacing, "\u00a0", "\\space");
+// Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{%
+defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace");
 defineSymbol(text, main, spacing, null, "\\!");
 defineSymbol(text, main, spacing, "\u00a0", "\\ ");
 defineSymbol(text, main, spacing, "\u00a0", "~");
@@ -573,6 +575,7 @@ defineSymbol(text, main, spacing, null, "\\enspace");
 defineSymbol(text, main, spacing, null, "\\qquad");
 defineSymbol(text, main, spacing, null, "\\quad");
 defineSymbol(text, main, spacing, "\u00a0", "\\space");
+defineSymbol(text, main, spacing, "\u00a0", "\\nobreakspace");
 defineSymbol(math, main, punct, ",", ",");
 defineSymbol(math, main, punct, ";", ";");
 defineSymbol(math, main, punct, ":", "\\colon");


Test patch:
diff --git a/test/katex-spec.js b/test/katex-spec.js
index 384a5e4f..e1d432af 100644
--- a/test/katex-spec.js
+++ b/test/katex-spec.js
@@ -2999,7 +2999,7 @@ describe("Symbols", function() {
     });
 
     it("should parse spacing functions in math or text mode", () => {
-        expect("A\\;B\\,C \\text{A\\;B\\,C}").toParse();
+        expect("A\\;B\\,C\\nobreakspace \\text{A\\;B\\,C\\nobreakspace}").toParse();
     });
 
     it("should render ligature commands like their unicode characters", () => {