w2l: Don't use \text in formulas if the argument is a plain number
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@132 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
dbf2d63269
commit
cc68f96a2c
3 changed files with 24 additions and 4 deletions
|
@ -2,6 +2,8 @@ Changelog for Writer2LaTeX version 1.0 -> 1.2
|
||||||
|
|
||||||
---------- version 1.1.9 ----------
|
---------- version 1.1.9 ----------
|
||||||
|
|
||||||
|
[w2l] The StarMath converter now leaves out the \text command if the argument is a plain number
|
||||||
|
|
||||||
[w2l] Properly detect and ignore empty formulas (avoiding any occurrences of $ $ in the document)
|
[w2l] Properly detect and ignore empty formulas (avoiding any occurrences of $ $ in the document)
|
||||||
|
|
||||||
[w2l] The StarMath converter now avoids redundant braces
|
[w2l] The StarMath converter now avoids redundant braces
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Version 1.2 (2012-02-23)
|
* Version 1.2 (2012-02-24)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class ConverterFactory {
|
||||||
|
|
||||||
// Version information
|
// Version information
|
||||||
private static final String VERSION = "1.1.9";
|
private static final String VERSION = "1.1.9";
|
||||||
private static final String DATE = "2012-02-23";
|
private static final String DATE = "2012-02-24";
|
||||||
|
|
||||||
/** Return the Writer2LaTeX version in the form
|
/** Return the Writer2LaTeX version in the form
|
||||||
* (major version).(minor version).(patch level)<br/>
|
* (major version).(minor version).(patch level)<br/>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*
|
*
|
||||||
* Copyright: 2002-2012 by Henrik Just
|
* Copyright: 2002-2012 by Henrik Just
|
||||||
*
|
*
|
||||||
* Version 1.2 (2012-02-23)
|
* Version 1.2 (2012-02-24)
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +26,9 @@
|
||||||
package writer2latex.latex;
|
package writer2latex.latex;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import writer2latex.util.*;
|
import writer2latex.util.*;
|
||||||
import writer2latex.latex.i18n.ClassicI18n;
|
import writer2latex.latex.i18n.ClassicI18n;
|
||||||
import writer2latex.latex.i18n.I18n;
|
import writer2latex.latex.i18n.I18n;
|
||||||
|
@ -705,6 +708,9 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
|
||||||
//private Float fBaseSize; // base size for the formula (usually 12pt)
|
//private Float fBaseSize; // base size for the formula (usually 12pt)
|
||||||
private I18n i18n;
|
private I18n i18n;
|
||||||
|
|
||||||
|
// Regular expression for numbers
|
||||||
|
Pattern numberPattern;
|
||||||
|
|
||||||
// Flags to track need for ooomath.sty definitions
|
// Flags to track need for ooomath.sty definitions
|
||||||
private boolean bDefeq = false;
|
private boolean bDefeq = false;
|
||||||
private boolean bLambdabar = false;
|
private boolean bLambdabar = false;
|
||||||
|
@ -721,6 +727,11 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
|
||||||
private boolean bNormalsubformula = false;
|
private boolean bNormalsubformula = false;
|
||||||
private boolean bMultiscripts = false;
|
private boolean bMultiscripts = false;
|
||||||
private boolean bMathoverstrike = false;
|
private boolean bMathoverstrike = false;
|
||||||
|
|
||||||
|
// Match a number (or the empty string)
|
||||||
|
private void createNumberPattern() {
|
||||||
|
numberPattern = Pattern.compile("^[0-9]*\\.?[0-9]*$");
|
||||||
|
}
|
||||||
|
|
||||||
// Constructor for stand alone StarMath converter
|
// Constructor for stand alone StarMath converter
|
||||||
public StarMathConverter() {
|
public StarMathConverter() {
|
||||||
|
@ -728,6 +739,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
|
||||||
i18n = new ClassicI18n(config);
|
i18n = new ClassicI18n(config);
|
||||||
configSymbols = config.getMathSymbols();
|
configSymbols = config.getMathSymbols();
|
||||||
bUseColor = config.useColor();
|
bUseColor = config.useColor();
|
||||||
|
createNumberPattern();
|
||||||
}
|
}
|
||||||
|
|
||||||
StarMathConverter(I18n i18n, LaTeXConfig config){
|
StarMathConverter(I18n i18n, LaTeXConfig config){
|
||||||
|
@ -735,6 +747,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
|
||||||
this.i18n = i18n;
|
this.i18n = i18n;
|
||||||
configSymbols = config.getMathSymbols();
|
configSymbols = config.getMathSymbols();
|
||||||
bUseColor = config.useColor();
|
bUseColor = config.useColor();
|
||||||
|
createNumberPattern();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
|
public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
|
||||||
|
@ -1243,7 +1256,12 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
|
||||||
else if (curToken.eType==Token.TEXT){
|
else if (curToken.eType==Token.TEXT){
|
||||||
sContent=curToken.sLaTeX;
|
sContent=curToken.sLaTeX;
|
||||||
nextToken();
|
nextToken();
|
||||||
return "\\text"+groupsp(sContent);
|
if (!numberPattern.matcher(sContent).matches()) {
|
||||||
|
return "\\text"+groupsp(sContent);
|
||||||
|
}
|
||||||
|
else { // In the special case that the text is simply a number, using \text is superflous
|
||||||
|
return sContent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (curToken.eType==Token.CHARACTER || curToken.eType==Token.NUMBER
|
else if (curToken.eType==Token.CHARACTER || curToken.eType==Token.NUMBER
|
||||||
|| tokenInGroup(TGroup.STANDALONE)){
|
|| tokenInGroup(TGroup.STANDALONE)){
|
||||||
|
|
Loading…
Add table
Reference in a new issue