| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Utility functions for mathml and mathjax rule store. | 6 * @fileoverview Utility functions for mathml and mathjax rule store. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('cvox.MathmlStoreUtil'); | 9 goog.provide('cvox.MathmlStoreUtil'); |
| 10 | 10 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 * @param {string} separators String representing a list of mfenced separators. | 117 * @param {string} separators String representing a list of mfenced separators. |
| 118 * @return {function(): string|null} A closure that returns the next separator | 118 * @return {function(): string|null} A closure that returns the next separator |
| 119 * for an mfenced expression starting with the first node in nodes. | 119 * for an mfenced expression starting with the first node in nodes. |
| 120 */ | 120 */ |
| 121 cvox.MathmlStoreUtil.nextSeparatorFunction = function(separators) { | 121 cvox.MathmlStoreUtil.nextSeparatorFunction = function(separators) { |
| 122 if (separators) { | 122 if (separators) { |
| 123 // Mathjax does not expand empty separators. | 123 // Mathjax does not expand empty separators. |
| 124 if (separators.match(/^\s+$/)) { | 124 if (separators.match(/^\s+$/)) { |
| 125 return null; | 125 return null; |
| 126 } else { | 126 } else { |
| 127 var sepList = separators.replace(/\s/g, '') | 127 var sepList = separators.replace(/\s/g, '').split('').filter(function(x) { |
| 128 .split('') | 128 return x; |
| 129 .filter(function(x) {return x;}); | 129 }); |
| 130 } | 130 } |
| 131 } else { | 131 } else { |
| 132 // When no separator is given MathML uses comma as default. | 132 // When no separator is given MathML uses comma as default. |
| 133 var sepList = [',']; | 133 var sepList = [',']; |
| 134 } | 134 } |
| 135 | 135 |
| 136 return function() { | 136 return function() { |
| 137 if (sepList.length > 1) { | 137 if (sepList.length > 1) { |
| 138 return sepList.shift(); | 138 return sepList.shift(); |
| 139 } | 139 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 168 if (nodes.length > 0) { | 168 if (nodes.length > 0) { |
| 169 var contentNodes = cvox.XpathUtil.evalXPath('../../content/*', nodes[0]); | 169 var contentNodes = cvox.XpathUtil.evalXPath('../../content/*', nodes[0]); |
| 170 } else { | 170 } else { |
| 171 var contentNodes = []; | 171 var contentNodes = []; |
| 172 } | 172 } |
| 173 return function() { | 173 return function() { |
| 174 var content = contentNodes.shift(); | 174 var content = contentNodes.shift(); |
| 175 return context + (content ? content.textContent : ''); | 175 return context + (content ? content.textContent : ''); |
| 176 }; | 176 }; |
| 177 }; | 177 }; |
| OLD | NEW |