W2L apostrophes and single quotation marks

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@63 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2010-05-11 08:00:49 +00:00
parent d7f1b41599
commit 83f0c7d224
7 changed files with 54 additions and 49 deletions

View file

@ -2,6 +2,9 @@ Changelog for Writer2LaTeX version 1.0 -> 1.2
---------- version 1.1.3 ----------
[w2l] Now exports apostrophe, single and double quotes using ' and ` characters (this creates nicer looking LaTeX files and
fixes a problem with hyphenation of words containing apostrophes)
[w2x] New style map "heading" to map styles applied to headings to custom styles.
[w2x] The option "use_list_hack" has been renamed to "list_formatting" with the new values "css1", "css1_hack" and "hard_labels".

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-05-09)
* Version 1.2 (2010-05-11)
*
*/
@ -33,7 +33,7 @@ public class ConverterFactory {
// Version information
private static final String VERSION = "1.1.3";
private static final String DATE = "2010-05-09";
private static final String DATE = "2010-05-11";
/** Return the Writer2LaTeX version in the form
* (major version).(minor version).(patch level)<br/>

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-03-15)
* Version 1.2 (2010-05-11)
*
*/
@ -452,7 +452,8 @@ public class ClassicI18n extends I18n {
private void convert(String s, int nStart, int nEnd, boolean bMathMode, String sLang, StringBuffer buf, int nFontenc) {
int nCurFontenc = nFontenc;
ucparser.reset(table,s,nStart,nEnd);
boolean bProtectDashes = true;
boolean bIsFirst = true; // Protect all dangerous characters at the start
char cProtect = '\u0000'; // Current character to protect
boolean bTempMathMode = false;
while (ucparser.next()) {
char c = ucparser.getChar();
@ -465,7 +466,7 @@ public class ClassicI18n extends I18n {
bTempMathMode = true;
}
buf.append(convertMathChar(c,nFontenc));
bProtectDashes = false;
cProtect = '\u0000';
}
else if (table.hasTextChar(c)) {
if (bTempMathMode) { // switch to text mode
@ -477,14 +478,12 @@ public class ClassicI18n extends I18n {
// The text character is valid in the current font encoding
// Note: Change of font encoding is greedy - change?
// Prevent unwanted --- ligatures
if (table.isDashes(c)) {
if (bProtectDashes) { buf.append("{}"); }
bProtectDashes = true;
}
else {
bProtectDashes = false;
// Prevent unwanted ligatures (-, ', `)
char cProtectThis = table.getProtectChar(c);
if (cProtectThis!='\u0000' && (cProtectThis==cProtect || bIsFirst)) {
buf.append("{}");
}
cProtect = cProtectThis;
setFlags(c,nCurFontenc);
if (ucparser.hasCombiningChar()) {
@ -504,7 +503,7 @@ public class ClassicI18n extends I18n {
else {
// The text character is valid in another font encoding
bProtectDashes = table.isDashes(c);
cProtect = table.getProtectChar(c);
int nFontenc1 = getFontenc(nFontencs);
setFlags(c,nFontenc1);
@ -534,6 +533,8 @@ public class ClassicI18n extends I18n {
else {
buf.append(notFound(c,nCurFontenc));
}
bIsFirst = false;
}
if (bTempMathMode) { // turn of math mode

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2007 by Henrik Just
* Copyright: 2002-2010 by Henrik Just
*
* All Rights Reserved.
*
* Version 0.5 (2007-07-24)
* Version 1.2 (2010-05-11)
*
*/
@ -37,7 +37,7 @@ class UnicodeCharacter implements Cloneable {
String sMath; // LaTeX representation in math mode
String sText; // LaTeX representation in text mode
int nFontencs; // Valid font encoding(s) for the text mode representation
boolean bDashes; // This character is represented by dashes (-,--,---)
char cProtect; // This character is represented by this character which may produce unwanted ligatures (-, ', `)
protected Object clone() {
UnicodeCharacter uc = new UnicodeCharacter();
@ -45,7 +45,7 @@ class UnicodeCharacter implements Cloneable {
uc.sMath = this.sMath;
uc.sText = this.sText;
uc.nFontencs = this.nFontencs;
uc.bDashes = this.bDashes;
uc.cProtect = this.cProtect;
return uc;
}
}

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2007 by Henrik Just
* Copyright: 2002-2010 by Henrik Just
*
* All Rights Reserved.
*
* Version 0.5 (2007-07-24)
* Version 1.2 (2010-05-11)
*
*/
@ -87,12 +87,12 @@ class UnicodeTable {
}
// Add a single text character to the table
protected void addTextChar(char c, String sLaTeX, int nFontencs, boolean bDashes){
protected void addTextChar(char c, String sLaTeX, int nFontencs, char cProtect){
int nRow=c/256; int nCol=c%256;
createEntry(nRow,nCol);
table[nRow].entries[nCol].sText=sLaTeX;
table[nRow].entries[nCol].nFontencs=nFontencs;
table[nRow].entries[nCol].bDashes=bDashes;
table[nRow].entries[nCol].cProtect=cProtect;
}
// Retrieve entry for a character (or null)
@ -144,11 +144,11 @@ class UnicodeTable {
return entry.nFontencs;
}
// Get dashes for text character
public boolean isDashes(char c) {
// Get ligature protect character for text character
public char getProtectChar(char c) {
UnicodeCharacter entry = getEntry(c);
if (entry==null) return false;
return entry.bDashes;
if (entry==null) return '\u0000';
return entry.cProtect;
}
// Get number of defined characters

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2009 by Henrik Just
* Copyright: 2002-2010 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2009-03-26)
* Version 1.2 (2010-05-11)
*
*/
@ -102,17 +102,18 @@ public class UnicodeTableHandler extends DefaultHandler{
table.addMathChar(c,table.getMathChar(eqc));
}
if (table.hasTextChar(eqc)) {
table.addTextChar(c,table.getTextChar(eqc),table.getFontencs(eqc),table.isDashes(eqc));
table.addTextChar(c,table.getTextChar(eqc),table.getFontencs(eqc),table.getProtectChar(eqc));
}
}
else {
String sType=attributes.getValue("char-type");
String sMath=attributes.getValue("math");
String sText=attributes.getValue("text");
boolean bDashes="true".equals(attributes.getValue("dashes"));
String sProtect=attributes.getValue("protect");
char cProtect = sProtect!=null && sProtect.length()>0 ? sProtect.charAt(0) : '\u0000';
if (sType!=null) table.addCharType(c,sType);
if (sMath!=null) table.addMathChar(c,sMath);
if (sText!=null) table.addTextChar(c,sText,nFontencs,bDashes);
if (sText!=null) table.addTextChar(c,sText,nFontencs,cProtect);
}
}
}
@ -125,7 +126,7 @@ public class UnicodeTableHandler extends DefaultHandler{
table.addMathChar(c,Character.toString(c));
}
if ("text".equals(sMode) || "both".equals(sMode)) {
table.addTextChar(c,Character.toString(c),nFontencs,false);
table.addTextChar(c,Character.toString(c),nFontencs,'\u0000');
}
}
}
@ -143,7 +144,7 @@ public class UnicodeTableHandler extends DefaultHandler{
table.addMathChar(c,Character.toString(c));
}
if (bText) {
table.addTextChar(c,Character.toString(c),nFontencs,false);
table.addTextChar(c,Character.toString(c),nFontencs,'\u0000');
}
}
}

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- This is a datafile used by Writer2LaTeX
Version 1.0 (2009-09-07)
Version 1.2 (2010-05-11)
The definitions for greek characters are contributed by interzone, info@interzone.gr
and extended by Johannis Likos. Additional bugfixes by Alexej Kryukov
@ -32,13 +32,13 @@ PART I: Common symbols, ascii only
<symbol char="0024" text="\$" math="\$"/>
<symbol char="0025" text="\%" math="\%"/>
<symbol char="0026" text="\&amp;" math="\&amp;"/>
<symbol char="0027" text="{\textquotesingle}" math="'"/>
<symbol char="0027" text="'" math="'" protect="'"/> <!-- changed from \textquotesingle (was this a good idea?) -->
<symbol char="0028" text="(" math="("/>
<symbol char="0029" text=")" math=")"/>
<symbol char="002A" text="*" math="*"/>
<symbol char="002B" text="+" math="+"/>
<symbol char="002C" text="," math=","/>
<symbol char="002D" text="-" math="-" dashes="true" />
<symbol char="002D" text="-" math="-" protect="-" />
<symbol char="002E" text="." math="."/>
<symbol char="002F" text="/" math="/"/>
<symbol char="0030" text="0" math="0"/>
@ -961,18 +961,18 @@ PART I: Common symbols, ascii only
<symbol char="200A" text="{\thinspace}" />
<symbol char="200C" text="\textcompwordmark" />
<symbol char="200D" text="" />
<symbol char="2010" text="-" dashes="true" />
<symbol char="2010" text="-" protect="-" />
<symbol char="2011" text="\nobreakdash-" /> <!-- requires ams -->
<symbol char="2012" text="--" dashes="true" />
<symbol char="2013" text="--" dashes="true" />
<symbol char="2014" text="---" dashes="true" />
<symbol char="2015" text="---" dashes="true" />
<symbol char="2012" text="--" protect="-" />
<symbol char="2013" text="--" protect="-" />
<symbol char="2014" text="---" protect="-" />
<symbol char="2015" text="---" protect="-" />
<symbol char="2016" text="{\textbardbl}" math="\|" />
<symbol char="2018" text="{\textquoteleft}" /> <!-- ` is unsafe -->
<symbol char="2019" text="{\textquoteright}" /> <!-- ' is unsafe -->
<symbol char="2018" text="`" protect="`"/> <!-- or \textquoteleft -->
<symbol char="2019" text="'" protect="'"/> <!-- or \textquoteright -->
<symbol char="201A" text="{\quotesinglbase}" />
<symbol char="201C" text="{\textquotedblleft}" /> <!-- `` is unsafe -->
<symbol char="201D" text="{\textquotedblright}" /> <!-- '' is unsafe -->
<symbol char="201C" text="``" protect="`"/> <!-- or \textquotedblleft -->
<symbol char="201D" text="''" protect="'"/> <!-- or \textquotedblright -->
<symbol char="201E" text="{\quotedblbase}" />
<symbol char="2020" text="{\dag}" math="{\dag}" />
<symbol char="2021" text="{\ddag}" math="{\ddag}" />
@ -2750,7 +2750,7 @@ definitions to the range 00-FF.
<symbol char="F0BB" math="{\approx}" />
<symbol char="F0BC" math="{\ldots}" />
<symbol char="F0BD" math="{\mid}" />
<symbol char="F0BE" text="---" dashes="true" />
<symbol char="F0BE" text="---" protect="-" />
<!--<symbol char="F0BF" math="??" />-->
<symbol char="F0C0" math="{\aleph}" />
<symbol char="F0C1" math="{\Im}" />
@ -2949,7 +2949,7 @@ definitions to the range 00-FF.
<symbol char="F02A" math="*"/>
<symbol char="F02B" math="+"/>
<symbol char="F02C" math=","/>
<symbol char="F02D" text="-" dashes="true" />
<symbol char="F02D" text="-" protect="-" />
<symbol char="F02E" math="."/>
<symbol char="F02F" math="/"/>
<symbol char="F030" math="0"/>
@ -3025,8 +3025,8 @@ definitions to the range 00-FF.
<symbol char="F078" math="x"/>
<symbol char="F079" math="y"/>
<symbol char="F07A" math="z"/>
<symbol char="F07B" text="{--}" dashes="true"/>
<symbol char="F07C" text="{---}" dashes="true"/>
<symbol char="F07B" text="{--}" protect="-"/>
<symbol char="F07C" text="{---}" protect="-"/>
<symbol char="F0A1" math="\Gamma " />
<symbol char="F0A2" math="\Delta "/>
<symbol char="F0A3" math="\Theta "/>
@ -3704,7 +3704,7 @@ definitions to the range 00-FF.
<symbol char="F038" text="\textsubarch{]}" />
<symbol char="F039" text="\textsubring{}" />
<symbol char="F030" text="\textsubtilde{}" />
<symbol char="F02d" text="-" dashes="true" />
<symbol char="F02d" text="-" protect="-" />
<symbol char="F03d" text="\textrtailn " />
<symbol char="F084" text="\textdoublepipe " />
<symbol char="F021" text="\'{}" />