Repository: Khan/KaTeX
Pull request #1030 (2017-12-22 19:10:22)

add \ae, \AE, \oe, \OE, \o, \O, \ss with unicode support
<img width="930" alt="screen shot 2017-12-22 at 12 00 52 pm" src="https://user-images.githubusercontent.com/1044413/34309779-118aea10-e711-11e7-9af9-d87681318a79.png">


kevinbarabash: > Technically, some lines in fontMetrics.js such as this one should be removed. You can also feel free to leave this to #992 if you'd like.

I can remove those.

Patch:
diff --git a/metrics/mapping.pl b/metrics/mapping.pl
index a9d91c4d..a9c94588 100755
--- a/metrics/mapping.pl
+++ b/metrics/mapping.pl
@@ -64,6 +64,13 @@ $map{cmr10} = {
     0x7E => [0x303,-500,0], # \tilde (combining)
     0x7F => 0xA8,           # \ddot
     0x7F => [0x308,-500,0], # \ddot (combining)
+    0x19 => 0xDF,           # sharp S
+    0x1A => 0xE6,           # ae ligature
+    0x1B => 0x153,          # oe ligature
+    0x1C => 0xF8,           # o with slash
+    0x1D => 0xC6,           # AE ligature
+    0x1E => 0x152,          # OE ligature
+    0x1F => 0xD8,           # O with slash
   ],
 };
 
diff --git a/src/fontMetrics.js b/src/fontMetrics.js
index b89d96f3..aaf8a715 100644
--- a/src/fontMetrics.js
+++ b/src/fontMetrics.js
@@ -103,7 +103,6 @@ const extraCharacterMap = {
     'Ã': 'A',
     'Ä': 'A',
     'Å': 'A',
-    'Æ': 'A',
     'Ç': 'C',
     'È': 'E',
     'É': 'E',
@@ -120,21 +119,18 @@ const extraCharacterMap = {
     'Ô': 'O',
     'Õ': 'O',
     'Ö': 'O',
-    'Ø': 'O',
     'Ù': 'U',
     'Ú': 'U',
     'Û': 'U',
     'Ü': 'U',
     'Ý': 'Y',
     'Þ': 'o',
-    'ß': 'B',
     'à': 'a',
     'á': 'a',
     'â': 'a',
     'ã': 'a',
     'ä': 'a',
     'å': 'a',
-    'æ': 'a',
     'ç': 'c',
     'è': 'e',
     'é': 'e',
@@ -151,7 +147,6 @@ const extraCharacterMap = {
     'ô': 'o',
     'õ': 'o',
     'ö': 'o',
-    'ø': 'o',
     'ù': 'u',
     'ú': 'u',
     'û': 'u',
diff --git a/src/fontMetricsData.js b/src/fontMetricsData.js
index 885a6437..e5e4f5b4 100644
--- a/src/fontMetricsData.js
+++ b/src/fontMetricsData.js
@@ -865,9 +865,16 @@ module.exports = {
         "176": [0, 0.69444, 0, 0],
         "177": [0.08333, 0.58333, 0, 0],
         "180": [0, 0.69444, 0, 0],
+        "198": [0, 0.68333, 0, 0],
         "215": [0.08333, 0.58333, 0, 0],
+        "216": [0.04861, 0.73194, 0, 0],
+        "223": [0, 0.69444, 0, 0],
+        "230": [0, 0.43056, 0, 0],
         "247": [0.08333, 0.58333, 0, 0],
+        "248": [0.09722, 0.52778, 0, 0],
         "305": [0, 0.43056, 0, 0],
+        "338": [0, 0.68333, 0, 0],
+        "339": [0, 0.43056, 0, 0],
         "567": [0.19444, 0.43056, 0, 0],
         "710": [0, 0.69444, 0, 0],
         "711": [0, 0.62847, 0, 0],
diff --git a/src/symbols.js b/src/symbols.js
index 5fe2787d..142f3c0e 100644
--- a/src/symbols.js
+++ b/src/symbols.js
@@ -648,6 +648,14 @@ defineSymbol(math, main, mathord, "\u0131", "\\imath");
 defineSymbol(math, main, mathord, "\u0237", "\\jmath");
 defineSymbol(text, main, textord, "\u0131", "\\i");
 defineSymbol(text, main, textord, "\u0237", "\\j");
+defineSymbol(text, main, textord, "\u00df", "\\ss", true);
+defineSymbol(text, main, textord, "\u00e6", "\\ae", true);
+defineSymbol(text, main, textord, "\u00e6", "\\ae", true);
+defineSymbol(text, main, textord, "\u0153", "\\oe", true);
+defineSymbol(text, main, textord, "\u00f8", "\\o", true);
+defineSymbol(text, main, textord, "\u00c6", "\\AE", true);
+defineSymbol(text, main, textord, "\u0152", "\\OE", true);
+defineSymbol(text, main, textord, "\u00d8", "\\O", true);
 defineSymbol(text, main, accent, "\u02ca", "\\'"); // acute
 defineSymbol(text, main, accent, "\u02cb", "\\`"); // grave
 defineSymbol(text, main, accent, "\u02c6", "\\^"); // circumflex


Test patch:
diff --git a/test/katex-spec.js b/test/katex-spec.js
index 448ae480..bd2a2641 100644
--- a/test/katex-spec.js
+++ b/test/katex-spec.js
@@ -2843,4 +2843,10 @@ describe("Symbols", function() {
     it("should parse \\text{\\i\\j}", () => {
         expect("\\text{\\i\\j}").toParse();
     });
+
+    it("should render ligature commands like their unicode characters", () => {
+        const commands = getBuilt("\\text{\\ae\\AE\\oe\\OE\\o\\O\\ss}");
+        const unicode = getBuilt("\\text{æÆœŒøØß}");
+        expect(commands).toEqual(unicode);
+    });
 });