This patch removes the support for the latexaccent inset, in favour of unicode chars (combining or not.)
I need some further help with the python part: revert is completely missing, I don't translate the "stroke" variants, and singular dot-less-i, dot-less-j. ...and do anyone remember what this "special caron" was about? This patch also changes the doc format to 250.
Index: src/insets/insetlatexaccent.C =================================================================== --- src/insets/insetlatexaccent.C (revision 14992) +++ src/insets/insetlatexaccent.C (working copy) @@ -1,626 +0,0 @@ -/** - * \file insetlatexaccent.C - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Lars Gullik Bjønnes - * - * Full author contact details are available in file CREDITS. - */ - -#include <config.h> - -#include "insetlatexaccent.h" - -#include "debug.h" -#include "language.h" -#include "LColor.h" -#include "lyxlex.h" -#include "lyxrc.h" -#include "metricsinfo.h" - -#include "frontends/font_metrics.h" -#include "frontends/Painter.h" - -#include "support/lstrings.h" - -using lyx::char_type; -using lyx::docstring; -using lyx::support::contains; -using lyx::support::trim; - -using std::endl; -using std::string; -using std::auto_ptr; -using std::ostream; - - -/* LatexAccent. Proper handling of accented characters */ -/* This part is done by Ivan Schreter, [EMAIL PROTECTED] */ -/* Later modified by Lars G. Bjønnes, [EMAIL PROTECTED] */ - -InsetLatexAccent::InsetLatexAccent() - : candisp(false) -{} - - -InsetLatexAccent::InsetLatexAccent(string const & str) - : contents(str) -{ - checkContents(); -} - - -auto_ptr<InsetBase> InsetLatexAccent::doClone() const -{ - return auto_ptr<InsetBase>(new InsetLatexAccent(contents)); -} - - -void InsetLatexAccent::checkContents() - // check, if we know the modifier and can display it ok on screen -{ - candisp = false; - - if (contents.empty() || contents.length() < 2) { - lyxerr[Debug::KEY] << "Cannot decode: " << contents << endl; - return; - } - - contents = trim(contents); - if (contents[0] != '\\') { // demand that first char is a '\\' - lyxerr[Debug::KEY] << "Cannot decode: " << contents << endl; - return; - } - - lyxerr[Debug::KEY] << "Decode: " << contents << endl; - - remdot = false; - plusasc = false; - plusdesc = false; - - switch (contents[1]) { // second char should be one of these - case '\'': // acute - modtype = ACUTE; // acute - plusasc = true; // at the top of character - break; - case '`': // grave - modtype = GRAVE; // grave - plusasc = true; // at the top - break; - case '=': // macron - modtype = MACRON; // macron - plusasc = true; // at the top - break; - case '~': // tilde - modtype = TILDE; // tilde - plusasc = true; // at the top - break; - case 'b': // underbar - modtype = UNDERBAR; // underbar - plusdesc = true; // at the bottom - break; - case 'c': // cedilla - modtype = CEDILLA; // cedilla - plusdesc = true; // at the bottom - break; - case 'd': // underdot - modtype = UNDERDOT; // underdot - plusdesc = true; // at the bottom - break; - case 'r': // circle - modtype = CIRCLE; // circle - plusasc = true; // at the top - break; - case 't': // tie - modtype = TIE; // tie - plusasc = true; // at the top - break; - case 'u': // breve - modtype = BREVE; // breve - plusasc = true; // at the top - break; - case 'v': // caron - modtype = CARON; // caron - plusasc = true; // at the top - break; - case 'q': // special caron - modtype = SPECIAL_CARON; // special caron - plusasc = true; // at the top - break; - case 'H': // hungarian umlaut - modtype = HUNGARIAN_UMLAUT; // hungarian umlaut - plusasc = true; // at the top - break; - case '"': // umlaut - modtype = UMLAUT; // umlaut - plusasc = true; // at the top - break; - case '.': // dot - modtype = DOT; // dot - plusasc = true; // at the top - break; - case '^': // circumflex - modtype = CIRCUMFLEX; // circumflex - plusasc = true; // at the top - break; - case 'k': // ogonek - modtype = OGONEK; // ogonek - plusdesc = true; - break; - case 'i': // dot-less-i - modtype = DOT_LESS_I; // dot-less-i - plusasc = true; // at the top (not really needed) - remdot = true; - break; - case 'j': // dot-less-j - modtype = DOT_LESS_J; // dot-less-j - plusasc = true; // at the top (not really needed) - remdot = true; - break; - case 'l': // lslash - modtype = lSLASH; - plusasc = true; // at the top (not really needed) - break; - case 'L': // lslash - modtype = LSLASH; - plusasc = true; // at the top (not really needed) - break; - default: - lyxerr[Debug::KEY] << "Default" << endl; - // unknown accent (or something else) - return; - } - - // we demand that third char is a '{' (Lgb) - if (contents[2] != '{') return; - - // special clause for \i{}, \j{} \l{} and \L{} - if ((modtype == DOT_LESS_I || modtype == DOT_LESS_J - || modtype == lSLASH || modtype == LSLASH) - && contents[3] == '}') { - switch (modtype) { - case DOT_LESS_I: ic = 'i'; break; - case DOT_LESS_J: ic = 'j'; break; - case lSLASH: ic = 'l'; break; - case LSLASH: ic = 'L'; break; - default: - // if this happens something is really wrong - lyxerr << "InsetLaTexAccent: weird error." << endl; - break; - } - //ic = (modtype == DOT_LESS_J ? 'j' : 'i'); - lyxerr[Debug::KEY] << "Contents: [" << contents << ']' - << ", ic: " << ic - << ", top: " << plusasc - << ", bot: " << plusdesc - << ", dot: " << remdot - << ", mod: " << modtype << endl; - // Special case for space - } else if (contents[3] == '}') { - ic = ' '; - } else { - int i = 3; - - // now get the char - ic = contents[3]; // i will always be 3 here - - // ic should now be a alfa-char or '\\' - if (ic == '\\') { - ic = contents[++i]; // will only allow \<foo>{\i} and \<foo>{\j} - if (ic == 'i' || ic == 'j') - remdot = true; - else - return; - } else if ((ic == 'i'|| ic == 'j') && contents[4] == '}') { - // Do a rewrite: \<foo>{i} --> \<foo>{\i} - string temp = contents; - temp.erase(3, string::npos); - temp += '\\'; - temp += char(ic); - for (string::size_type j = 4; - j < contents.length(); ++j) - temp+= contents[j]; - contents= temp; - ++i; - remdot = true; - } - - // demand a '}' at the end - if (contents[++i] != '}' && contents[++i]) return; - - // fine, the char is properly decoded now (hopefully) - lyxerr[Debug::KEY] << "Contents: [" << contents << ']' - << ", ic: " << ic - << ", top: " << plusasc - << ", bot: " << plusdesc - << ", dot: " << remdot - << ", mod: " << modtype << endl; - } - candisp = true; -} - - -void InsetLatexAccent::metrics(MetricsInfo & mi, Dimension & dim) const -{ - LyXFont & font = mi.base.font; - // This function is a bit too simplistic and is just a - // "try to make a fit for all accents" approach, to - // make it better we need to know what kind of accent is - // used and add to max based on that. - if (candisp) { - if (ic == ' ') - dim.asc = font_metrics::ascent('a', font); - else - dim.asc = font_metrics::ascent(ic, font); - if (plusasc) - dim.asc += (font_metrics::maxAscent(font) + 3) / 3; - - if (ic == ' ') - dim.des = font_metrics::descent('a', font); - else - dim.des = font_metrics::descent(ic, font); - if (plusdesc) - dim.des += 3; - - dim.wid = font_metrics::width(ic, font); - } else { - dim.asc = font_metrics::maxAscent(font) + 4; - dim.des = font_metrics::maxDescent(font) + 4; - docstring dcon(contents.begin(), contents.end()); - dim.wid = font_metrics::width(dcon, font) + 4; - } - dim_ = dim; -} - - -int InsetLatexAccent::lbearing(LyXFont const & font) const -{ - return font_metrics::lbearing(ic, font); -} - - -int InsetLatexAccent::rbearing(LyXFont const & font) const -{ - return font_metrics::rbearing(ic, font); -} - - -bool InsetLatexAccent::displayISO8859_9(PainterInfo & pi, int x, int y) const -{ - unsigned char tmpic = ic; - - switch (modtype) { - - case CEDILLA: { - if (ic == 'c') tmpic = '\xe7'; - if (ic == 'C') tmpic = '\xc7'; - if (ic == 's') tmpic = '\xfe'; - if (ic == 'S') tmpic = '\xde'; - break; - } - - case BREVE: { - if (ic == 'g') tmpic = '\xf0'; - if (ic == 'G') tmpic = '\xd0'; - break; - } - - case UMLAUT: { - if (ic == 'o') tmpic = '\xf6'; - if (ic == 'O') tmpic = '\xd6'; - if (ic == 'u') tmpic = '\xfc'; - if (ic == 'U') tmpic = '\xdc'; - break; - } - - case DOT: - if (ic == 'I') tmpic = '\xdd'; - break; - - case DOT_LESS_I: - tmpic = '\xfd'; - break; - - default: - return false; - } - - if (tmpic == ic) - return false; - - pi.pain.text(x, y, char(tmpic), pi.base.font); - return true; -} - - -void InsetLatexAccent::drawAccent(PainterInfo const & pi, int x, int y, - char_type accent) const -{ - LyXFont const & font = pi.base.font; - x -= font_metrics::center(accent, font); - y -= font_metrics::ascent(ic, font); - y -= font_metrics::descent(accent, font); - y -= font_metrics::height(accent, font) / 2; - pi.pain.text(x, y, accent, font); -} - - -void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const -{ - if (lyxrc.font_norm_type == LyXRC::ISO_8859_9) - if (displayISO8859_9(pi, x, baseline)) - return; - - // All the manually drawn accents in this function could use an - // overhaul. Different ways of drawing (what metrics to use) - // should also be considered. - - LyXFont font = pi.base.font; - if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) - font.setLanguage(english_language); - - if (candisp) { - int x2 = int(x + (rbearing(font) - lbearing(font)) / 2); - int hg; - int y; - if (plusasc) { - // mark at the top - hg = font_metrics::maxDescent(font); - y = baseline - dim_.asc; - if (font.shape() == LyXFont::ITALIC_SHAPE) - x2 += int(0.8 * hg); // italic - } else { - // at the bottom - hg = dim_.des; - y = baseline; - } - - double hg35 = hg * 0.6; - - // display with proper accent mark - // first the letter - pi.pain.text(x, baseline, ic, font); - - if (remdot) { - int tmpvar = baseline - font_metrics::ascent('i', font); - int tmpx = 0; - if (font.shape() == LyXFont::ITALIC_SHAPE) - tmpx += int(0.8 * hg); // italic - lyxerr[Debug::KEY] << "Removing dot." << endl; - // remove the dot first - pi.pain.fillRectangle(x + tmpx, tmpvar, dim_.wid, - font_metrics::ascent('i', pi.base.font) - - font_metrics::ascent('x', pi.base.font) - 1, - backgroundColor()); - // the five lines below is a simple hack to - // make the display of accent 'i' and 'j' - // better. It makes the accent be written - // closer to the top of the dot-less 'i' or 'j'. - char tmpic = ic; // store the ic when we - ic = 'x'; // calculates the ascent of -#ifdef WITH_WARNINGS -#warning metrics? -#endif - int asc = ascent(); // the dot-less version (here: 'x') - ic = tmpic; // set the orig ic back - y = baseline - asc; // update to new y coord. - } - - // now the rest - draw within (x, y, x + wid, y + hg) - switch (modtype) { - case ACUTE: - //drawAccent(pi, x2, baseline, '\xB4'); - drawAccent(pi, x2, baseline, 0xB4); - break; - - case GRAVE: - //drawAccent(pi, x2, baseline, '\x60'); - drawAccent(pi, x2, baseline, 0x60); - break; - - case MACRON: - //drawAccent(pi, x2, baseline, '\xAF'); - drawAccent(pi, x2, baseline, 0xAF); - break; - - case TILDE: - drawAccent(pi, x2, baseline, '~'); - break; - - case UNDERBAR: { - char_type const underbar = 0x5F; //('\x5F'); - pi.pain.text(x2 - font_metrics::center(underbar, font), - baseline, underbar, font); - break; - } - - case CEDILLA: { - char_type const cedilla = 0xB8; //('\xB8'); - pi.pain.text(x2 - font_metrics::center(cedilla, font), - baseline, cedilla, font); - break; - } - - case UNDERDOT: - pi.pain.text(x2 - font_metrics::center('.', font), - int(baseline + 1.5 * font_metrics::height('.', font)), - '.', font); - break; - - case DOT: - drawAccent(pi, x2, baseline, '.'); - break; - - case CIRCLE: - //drawAccent(pi, x2, baseline, '\xB0'); - drawAccent(pi, x2, baseline, 0xB0); - break; - - case TIE: - pi.pain.arc(int(x2 + hg35), y + hg / 2, 2 * hg, hg, 0, 360 * 32, - LColor::foreground); - break; - - case BREVE: - pi.pain.arc(int(x2 - hg / 2), y, hg, hg, 0, -360*32, - LColor::foreground); - break; - - case CARON: { - int xp[3], yp[3]; - xp[0] = int(x2 - hg35); yp[0] = int(y + hg35); - xp[1] = int(x2); yp[1] = int(y + hg); - xp[2] = int(x2 + hg35); yp[2] = int(y + hg35); - pi.pain.lines(xp, yp, 3, LColor::foreground); - break; - } - - case SPECIAL_CARON: { - switch (ic) { - case 'L': dim_.wid = int(4.0 * dim_.wid / 5.0); break; - case 't': y -= int(hg35 / 2.0); break; - } - int xp[3], yp[3]; - xp[0] = int(x + dim_.wid); - yp[0] = int(y + hg35 + hg); - - xp[1] = int(x + dim_.wid + (hg35 / 2.0)); - yp[1] = int(y + hg + (hg35 / 2.0)); - - xp[2] = int(x + dim_.wid + (hg35 / 2.0)); - yp[2] = y + int(hg); - - pi.pain.lines(xp, yp, 3, LColor::foreground); - break; - } - - case HUNGARIAN_UMLAUT: - drawAccent(pi, x2 - font_metrics::center('´', font), baseline, '´'); - drawAccent(pi, x2 + font_metrics::center('´', font), baseline, '´'); - break; - - case UMLAUT: - drawAccent(pi, x2, baseline, '"'); - break; - - case CIRCUMFLEX: - drawAccent(pi, x2, baseline, '\x5E'); - break; - - case OGONEK: { - // this does probably not look like an ogonek, so - // it should certainly be refined - int xp[4], yp[4]; - - xp[0] = x2; - yp[0] = y; - - xp[1] = x2; - yp[1] = y + int(hg35); - - xp[2] = int(x2 - hg35); - yp[2] = y + hg / 2; - - xp[3] = x2 + hg / 4; - yp[3] = y + int(hg); - - pi.pain.lines(xp, yp, 4, LColor::foreground); - break; - } - - case lSLASH: - case LSLASH: { - int xp[2], yp[2]; - - xp[0] = x; - yp[0] = y + int(3 * hg); - - xp[1] = int(x + dim_.wid * 0.75); - yp[1] = y + int(hg); - - pi.pain.lines(xp, yp, 2, LColor::foreground); - break; - } - - case DOT_LESS_I: // dotless-i - case DOT_LESS_J: // dotless-j - // nothing to do for these - break; - } - - } else { - pi.pain.fillRectangle(x + 1, - baseline - dim_.asc + 1, dim_.wid - 2, - dim_.asc + dim_.des - 2, - backgroundColor()); - pi.pain.rectangle(x + 1, baseline - dim_.asc + 1, - dim_.wid - 2, dim_.asc + dim_.des - 2, - LColor::foreground); - docstring dcon(contents.begin(), contents.end()); - pi.pain.text(x + 2, baseline, dcon, font); - } -} - - -void InsetLatexAccent::write(Buffer const &, ostream & os) const -{ - os << "\\i " << contents << "\n"; -} - - -void InsetLatexAccent::read(Buffer const &, LyXLex & lex) -{ - lex.eatLine(); - contents = lex.getString(); - checkContents(); -} - - -int InsetLatexAccent::latex(Buffer const &, ostream & os, - OutputParams const &) const -{ - os << contents; - return 0; -} - - -int InsetLatexAccent::plaintext(Buffer const &, ostream & os, - OutputParams const &) const -{ - os << contents; - return 0; -} - - -int InsetLatexAccent::docbook(Buffer const &, ostream & os, - OutputParams const &) const -{ - os << contents; - return 0; -} - - -int InsetLatexAccent::textString(Buffer const & buf, ostream & os, - OutputParams const & op) const -{ - return plaintext(buf, os, op); -} - - -bool InsetLatexAccent::directWrite() const -{ - return true; -} - - -InsetBase::Code InsetLatexAccent::lyxCode() const -{ - return InsetBase::ACCENT_CODE; -} - - -ostream & operator<<(ostream & o, InsetLatexAccent::ACCENT_TYPES at) -{ - return o << int(at); -} Index: src/insets/insetlatexaccent.h =================================================================== --- src/insets/insetlatexaccent.h (revision 14992) +++ src/insets/insetlatexaccent.h (working copy) @@ -1,150 +0,0 @@ -// -*- C++ -*- -/** - * \file insetlatexaccent.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Lars Gullik Bjønnes - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef INSET_LATEX_ACCENT_H -#define INSET_LATEX_ACCENT_H - -#include "inset.h" -#include "support/types.h" - -class Dimension; - - -/** Insertion of accents - - Proper handling of accented characters. - This is class is supposed to handle all LaTeX accents, it - is also possible that the class will change a bit so that - it also can handle other special characters (e.g. Hstroke) - Initiated by Ivan Schreter, later modified by Lgb. - */ -class InsetLatexAccent : public InsetOld { -public: - /// - InsetLatexAccent(); - /// - explicit InsetLatexAccent(std::string const & str); - /// - void metrics(MetricsInfo &, Dimension &) const; - /// - void draw(PainterInfo & pi, int x, int y) const; - /// - int lbearing(LyXFont const & font) const; - /// - int rbearing(LyXFont const & font) const; - /// - bool displayISO8859_9(PainterInfo & pi, int x, int y) const; - /// - void write(Buffer const &, std::ostream &) const; - /// - void read(Buffer const &, LyXLex & lex); - /// - int latex(Buffer const &, std::ostream &, - OutputParams const &) const; - /// - int plaintext(Buffer const &, std::ostream &, - OutputParams const &) const; - /// - int docbook(Buffer const &, std::ostream &, - OutputParams const &) const; - /// the string that is passed to the TOC - virtual int textString(Buffer const &, std::ostream & os, - OutputParams const &) const; - /// - bool directWrite() const; - /// - InsetBase::Code lyxCode()const; - /// - inline bool canDisplay(); - // should this inset be handled like a normal charater - bool isChar() const { return true; } - - /// is this equivalent to a letter? - virtual bool isLetter() const { return candisp; } - - /// all the accent types - enum ACCENT_TYPES{ - /// - ACUTE, // 0 - /// - GRAVE, - /// - MACRON, - /// - TILDE, - /// - UNDERBAR, - /// - CEDILLA, // 5 - /// - UNDERDOT, - /// - CIRCLE, - /// - TIE, - /// - BREVE, - /// - CARON, // 10 - /// - SPECIAL_CARON, - /// - HUNGARIAN_UMLAUT, - /// - UMLAUT, - /// - DOT, - /// - CIRCUMFLEX, // 15 - /// - OGONEK, - /// - DOT_LESS_I, - /// - DOT_LESS_J, // 18 - /// - lSLASH, - /// - LSLASH - }; -private: - friend std::ostream & operator<<(std::ostream &, ACCENT_TYPES); - - virtual std::auto_ptr<InsetBase> doClone() const; - - /// Check if we know the modifier and can display it ok on screen. - void checkContents(); - /// - void drawAccent(PainterInfo const & pi, int x, int y, lyx::char_type accent) const; - /// - std::string contents; - /// can display as proper char - bool candisp; - /// modifier type - ACCENT_TYPES modtype; - - /// remove dot from 'i' and 'j' or transform l, L into lslash, LSLaSH - bool remdot; - /// add something to ascent - accent at the top - bool plusasc; - /// add something to descent - underlined char - bool plusdesc; - /// international char - mutable char ic; -}; - - -bool InsetLatexAccent::canDisplay() -{ - return candisp; -} - -#endif Index: src/insets/Makefile.am =================================================================== --- src/insets/Makefile.am (revision 14992) +++ src/insets/Makefile.am (working copy) @@ -77,8 +77,6 @@ insetindex.h \ insetlabel.C \ insetlabel.h \ - insetlatexaccent.C \ - insetlatexaccent.h \ insetline.C \ insetline.h \ insetmarginal.h \ @@ -110,7 +108,7 @@ insetvspace.C \ insetvspace.h \ insetwrap.h \ - insetwrap.C + insetwrap.C # insetlist.C \ # insetlist.h \ @@ -118,4 +116,3 @@ # insetsection.C \ # insettheorem.C \ # insettheorem.h - Index: src/buffer.C =================================================================== --- src/buffer.C (revision 14992) +++ src/buffer.C (working copy) @@ -146,7 +146,7 @@ namespace { -int const LYX_FORMAT = 249; +int const LYX_FORMAT = 250; } // namespace anon Index: src/trans_mgr.C =================================================================== --- src/trans_mgr.C (revision 14992) +++ src/trans_mgr.C (working copy) @@ -21,8 +21,6 @@ #include "lyxtext.h" #include "trans.h" -#include "insets/insetlatexaccent.h" - #include "support/lstrings.h" using lyx::support::split; @@ -273,6 +271,7 @@ void TransManager::insert(string const & str, LyXText * text) { +#if 0 // Go through the character encoding only if the current // encoding (chset_->name()) matches the current font_norm // (lyrxc->font_norm) @@ -296,6 +295,7 @@ } string const tmp(1, static_cast<char>(enc.second)); insertVerbatim(tmp, text); +#endif } Index: src/text.C =================================================================== --- src/text.C (revision 14992) +++ src/text.C (working copy) @@ -58,7 +58,6 @@ #include "insets/insettext.h" #include "insets/insetbibitem.h" #include "insets/insethfill.h" -#include "insets/insetlatexaccent.h" #include "insets/insetline.h" #include "insets/insetnewline.h" #include "insets/insetpagebreak.h" @@ -299,10 +298,6 @@ par.insertInset(par.size(), inset.release(), font, change); } - } else if (token == "\\i") { - auto_ptr<InsetBase> inset(new InsetLatexAccent); - inset->read(buf, lex); - par.insertInset(par.size(), inset.release(), font, change); } else if (token == "\\backslash") { par.insertChar(par.size(), '\\', font, change); } else if (token == "\\newline") { Index: lib/lyx2lyx/LyX.py =================================================================== --- lib/lyx2lyx/LyX.py (revision 14992) +++ lib/lyx2lyx/LyX.py (working copy) @@ -73,7 +73,7 @@ ("1_2", [220], generate_minor_versions("1.2" , 4)), ("1_3", [221], generate_minor_versions("1.3" , 7)), ("1_4", range(222,246), generate_minor_versions("1.4" , 3)), - ("1_5", range(246,250), generate_minor_versions("1.5" , 0))] + ("1_5", range(246,251), generate_minor_versions("1.5" , 0))] def formats_list(): Index: lib/lyx2lyx/lyx_1_5.py =================================================================== --- lib/lyx2lyx/lyx_1_5.py (revision 14992) +++ lib/lyx2lyx/lyx_1_5.py (working copy) @@ -20,6 +20,8 @@ """ Convert files to the file format generated by lyx 1.5""" import re +import unicodedata + from parser_tools import find_token, find_token_exact, find_tokens, find_end_of, get_value from LyX import get_encoding @@ -231,6 +233,55 @@ document.encoding = get_encoding(document.language, document.inputencoding, 248) +def find_end_of_accent(str, i): + return i + 5 + +def _convert_accent(accent): + type = accent[1] + char = accent[3:-1] + if char[0] == "\\": + char = char[1:] + accent_map = { + "`" : 0x0309, # grave + "'" : 0x0301, # acute + "^" : 0x0302, # circumflex + "~" : 0x0303, # tilde + "=" : 0x0304, # macron + "u" : 0x0306, # breve + "." : 0x0307, # dot above + "\"": 0x0308, # diaresis + "r" : 0x030a, # ring above + "H" : 0x030b, # double acute + "v" : 0x030c, # caron + "b" : 0x0320, # minus sign below + "d" : 0x0323, # dot below + "c" : 0x0327, # cedilla + "k" : 0x0328, # ogonek + "t" : 0x0361 # tie + } + a = accent_map.get(type) + if a: + return unicodedata.normalize("NFKC", "%s%s" % (char, unichr(a))) + +def convert_accent(document): + i = 0 + while 1: + i = find_token(document.body, "\\i ", i) + if i == -1: + return + j = find_end_of_accent(document.body, i + 1) + if j == -1: + document.warning("Malformed LyX document: Could not find end of accent.") + continue + accent = document.body[i][3:] + a = _convert_accent(accent) + document.body[i] = a + i += 1 + +def revert_accent(document): + pass + + ## # Conversion hub # @@ -239,9 +290,11 @@ convert = [[246, []], [247, [convert_font_settings]], [248, []], - [249, [convert_utf8]]] + [249, [convert_utf8]], + [250, [convert_accent]]] -revert = [[248, [revert_utf8]], +revert = [[249, [revert_accent]], + [248, [revert_utf8]], [247, [revert_booktabs]], [246, [revert_font_settings]], [245, [revert_framed]]]
-- Lgb