@@ -23,12 +23,14 @@ function getSize(_selection, _dimension) {
23
23
return _selection . node ( ) . getBoundingClientRect ( ) [ _dimension ] ;
24
24
}
25
25
26
+ var FIND_TEX = / ( [ ^ $ ] * ) ( [ $ ] + [ ^ $ ] * [ $ ] + ) ( [ ^ $ ] * ) / ;
27
+
26
28
exports . convertToTspans = function ( _context , gd , _callback ) {
27
29
var str = _context . text ( ) ;
28
30
29
31
// Until we get tex integrated more fully (so it can be used along with non-tex)
30
32
// allow some elements to prohibit it by attaching 'data-notex' to the original
31
- var tex = ( ! _context . attr ( 'data-notex' ) ) && str . match ( / ( [ ^ $ ] * ) ( [ $ ] + [ ^ $ ] * [ $ ] + ) ( [ ^ $ ] * ) / ) ;
33
+ var tex = ( ! _context . attr ( 'data-notex' ) ) && str . match ( FIND_TEX ) ;
32
34
var parent = d3 . select ( _context . node ( ) . parentNode ) ;
33
35
if ( parent . empty ( ) ) return ;
34
36
var svgClass = ( _context . attr ( 'class' ) ) ? _context . attr ( 'class' ) . split ( ' ' ) [ 0 ] : 'text' ;
@@ -138,9 +140,12 @@ exports.convertToTspans = function(_context, gd, _callback) {
138
140
139
141
// MathJax
140
142
143
+ var LT_MATCH = / ( < | & l t ; | & # 6 0 ; ) / g;
144
+ var GT_MATCH = / ( > | & g t ; | & # 6 2 ; ) / g;
145
+
141
146
function cleanEscapesForTex ( s ) {
142
- return s . replace ( / ( < | & l t ; | & # 6 0 ; ) / g , '\\lt ' )
143
- . replace ( / ( > | & g t ; | & # 6 2 ; ) / g , '\\gt ' ) ;
147
+ return s . replace ( LT_MATCH , '\\lt ' )
148
+ . replace ( GT_MATCH , '\\gt ' ) ;
144
149
}
145
150
146
151
function texToSVG ( _texString , _config , _callback ) {
0 commit comments