Math: Remove math_prefix content prior to parsing cell values

This commit is contained in:
Rob Garrison 2016-11-26 05:24:19 -06:00
parent 0686e554d8
commit 12cde473d3

View File

@ -29,7 +29,15 @@
.split(' ').join('.tsmath '),
processText : function( c, $cell ) {
var txt = ts.getElementText( c, $cell, math.getCellIndex( $cell ) );
var tmp,
txt = ts.getElementText( c, $cell, math.getCellIndex( $cell ) ),
prefix = c.widgetOptions.math_prefix;
if ( /</.test( prefix ) ) {
// prefix contains HTML; remove it & any text before using formatFloat
tmp = $( '<div>' + prefix + '</div>' ).text()
.replace(/\{content\}/g, '').trim();
txt = txt.replace( tmp, '' );
}
txt = ts.formatFloat( txt.replace( /[^\w,. \-()]/g, '' ), c.table ) || 0;
// isNaN('') => false
return isNaN( txt ) ? 0 : txt;