diff --git a/lib/examples/europeCV.lyx b/lib/examples/europeCV.lyx index 1ab028474f..c32b876a04 100644 --- a/lib/examples/europeCV.lyx +++ b/lib/examples/europeCV.lyx @@ -1,38 +1,12 @@ -#LyX 2.0 created this file. For more info see http://www.lyx.org/ -\lyxformat 413 +#LyX 2.1 created this file. For more info see http://www.lyx.org/ +\lyxformat 449 \begin_document \begin_header \textclass europecv \begin_preamble -\usepackage{graphicx} - -% Define personal data -\ecvname{Testmann, Paul} -\ecvfootername{Paul Testmann} -\ecvnationality{Swiss} -\ecvdateofbirth{June 23, 1962} -\ecvaddress{Teststreet\newline 03333 Nicecity\newline Switzerland} -\ecvemail{testman@testman.xx} -% the optional phnoe number is for the mobile -\ecvtelephone[+43(0)777 7777]{+43(0)999 9999} - -% for the gender and fax number -%\ecvgender{male} -%\ecvfax{fax} - -% define text or image alignment and position: -% in this case the image is shifted 6cm to the right -\ecvbeforepicture{\hspace{6cm}} - -% image -\ecvpicture[height=3cm]{CV-image} - -% define text or space after the image -% in this case the following shifted 2cm to the image -\ecvafterpicture{\ecvspace{-2cm}} - -% if you e.g. only want the page number to be printed in the footer -%\ecvpage{\thepage} +% to handle the picture +% only load the package of not already loaded +\@ifundefined{rotatebox}{\usepackage{graphicx}}{} \end_preamble \options nologo \use_default_options false @@ -44,13 +18,13 @@ \font_roman default \font_sans default \font_typewriter default +\font_math auto \font_default_family default \use_non_tex_fonts false \font_sc false \font_osf false \font_sf_scale 100 \font_tt_scale 100 - \graphics default \default_output_format default \output_sync 0 @@ -61,15 +35,21 @@ \use_hyperref false \papersize default \use_geometry true -\use_amsmath 1 -\use_esint 1 -\use_mhchem 1 -\use_mathdots 1 +\use_package amsmath 1 +\use_package amssymb 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 0 +\use_package mhchem 1 +\use_package undertilde 0 \cite_engine basic +\cite_engine_type numerical +\biblio_style plain \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false +\justification true \use_refstyle 0 \index Index \shortcut idx @@ -79,8 +59,8 @@ \topmargin 2cm \rightmargin 2cm \bottommargin 3cm -\secnumdepth 3 -\tocdepth 3 +\secnumdepth 1 +\tocdepth 1 \paragraph_separation skip \defskip medskip \quotes_language english @@ -96,12 +76,72 @@ \begin_body -\begin_layout Begin -\begin_inset Note Note +\begin_layout Name +Testmann, Paul +\end_layout + +\begin_layout FooterName +Paul Testmann +\end_layout + +\begin_layout Nationality +Swiss +\end_layout + +\begin_layout Birthday +June 23, 1962 +\end_layout + +\begin_layout Address +Teststreet +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + + +\backslash +newline +\end_layout + +\end_inset + +03333 Nicecity +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + + +\backslash +newline +\end_layout + +\end_inset + +Switzerland +\end_layout + +\begin_layout Email +testman@testman.ch +\end_layout + +\begin_layout Telephone +\begin_inset Argument 1 status open \begin_layout Plain Layout -Keep entries with green labels empty! ++43(0)777 7777 +\end_layout + +\end_inset + ++43(0)999 9999 +\begin_inset Note Note +status collapsed + +\begin_layout Plain Layout +The mobile number is optional. \end_layout \end_inset @@ -109,17 +149,128 @@ Keep entries with green labels empty! \end_layout -\begin_layout Standard +\begin_layout Gender +Male \begin_inset Note Note +status collapsed + +\begin_layout Plain Layout +optional +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Fax +Fax number +\begin_inset Note Note +status collapsed + +\begin_layout Plain Layout +optional +\end_layout + +\end_inset + + +\end_layout + +\begin_layout BeforePicture +\begin_inset space \hspace*{} +\length 6cm +\end_inset + + +\begin_inset Note Note +status collapsed + +\begin_layout Plain Layout +optional, alignment and position of the picture or text, in this case the + picture is shifted 6 +\begin_inset space \thinspace{} +\end_inset + +cm to the right +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Picture +\begin_inset Argument 1 status open \begin_layout Plain Layout +height=3cm +\end_layout -\series bold -Note: -\series default - The personal data like your name, image, address, etc. - are set in the document preamble. +\end_inset + +CV-image +\begin_inset Note Note +status collapsed + +\begin_layout Plain Layout +The name of the image file. + The optional size is in this case the height the photo is resized to. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout AfterPicture +\begin_inset Flex VerticalSpace +status open + +\begin_layout Plain Layout +-2cm +\end_layout + +\end_inset + + +\begin_inset Note Note +status collapsed + +\begin_layout Plain Layout +optional, in this case the following material is shifted 2 +\begin_inset space \thinspace{} +\end_inset + +cm to the picture +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Page +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + + +\backslash +thepage +\end_layout + +\end_inset + + +\begin_inset Note Note +status collapsed + +\begin_layout Plain Layout +optional, redefines what is printed in the footer, in this case only the + page number \end_layout \end_inset @@ -133,7 +284,34 @@ status open \begin_layout Plain Layout The europecv-class offers lots of customization possibilities; to find out - more, look at its documentation. + more, look at its documentation: +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex URL +status open + +\begin_layout Plain Layout + +http://mirrors.ctan.org/macros/latex/contrib/europecv/europecv.pdf +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Begin +\begin_inset Note Note +status open + +\begin_layout Plain Layout +Keep entries with green labels empty! \end_layout \end_inset @@ -159,13 +337,11 @@ Education \end_layout \begin_layout Item -2003--2006 -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +2003--2006 \end_layout \end_inset @@ -174,13 +350,11 @@ Master of Economics, Institution, City, Country, Description \end_layout \begin_layout Item -2001--2003 -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +2001--2003 \end_layout \end_inset @@ -193,13 +367,11 @@ Master Thesis \end_layout \begin_layout BulletedItem -Title -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +Title \end_layout \end_inset @@ -210,13 +382,11 @@ Title of the thesis \end_layout \begin_layout BulletedItem -Supervisors -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +Supervisors \end_layout \end_inset @@ -225,13 +395,11 @@ Names of supervisors \end_layout \begin_layout BulletedItem -Description -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +Description \end_layout \end_inset @@ -246,13 +414,11 @@ Experience \end_layout \begin_layout Item -February 2006--current -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +2006--current \end_layout \end_inset @@ -261,13 +427,11 @@ Maintainer of OpenSource projects \end_layout \begin_layout Item -2005--2006 -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +2005--2006 \end_layout \end_inset @@ -281,8 +445,8 @@ Languages \end_layout \begin_layout MotherTongue -\begin_inset Argument -status collapsed +\begin_inset Argument 1 +status open \begin_layout Plain Layout 10pt @@ -315,8 +479,8 @@ The optional parameter is the vertical height behind the item; negative status collapsed \begin_layout Plain Layout -Inserts the language level explanation and sets the symbol for the reference - footnote. +Optional, inserts the language level explanation and sets the symbol for + the reference footnote. \end_layout @@ -326,18 +490,20 @@ Inserts the language level explanation and sets the symbol for the reference \end_layout \begin_layout Language -German -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +German \end_layout \end_inset +\begin_inset Argument 3 +status open + +\begin_layout Plain Layout \begin_inset ERT status collapsed @@ -351,17 +517,15 @@ ecvBTwo \end_inset -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -}{ \end_layout \end_inset +\begin_inset Argument 4 +status open + +\begin_layout Plain Layout \begin_inset ERT status collapsed @@ -375,17 +539,15 @@ ecvCOne \end_inset -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -}{ \end_layout \end_inset +\begin_inset Argument 5 +status open + +\begin_layout Plain Layout \begin_inset ERT status collapsed @@ -399,17 +561,15 @@ ecvATwo \end_inset -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -}{ \end_layout \end_inset +\begin_inset Argument 6 +status open + +\begin_layout Plain Layout \begin_inset ERT status collapsed @@ -423,12 +583,6 @@ ecvATwo \end_inset -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -}{ \end_layout \end_inset @@ -447,12 +601,22 @@ ecvBOne \end_inset +\begin_inset Note Note +status collapsed + +\begin_layout Plain Layout +The last info is the level how good you think you can write. +\end_layout + +\end_inset + + \begin_inset Note Note status open \begin_layout Plain Layout -The language level codes can be found in the documentation of the europecv-packa -ge. +The language level codes can be found in the documentation of the package + europecv. \end_layout \end_inset @@ -461,18 +625,20 @@ ge. \end_layout \begin_layout LastLanguage -Italian -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +Italian \end_layout \end_inset +\begin_inset Argument 3 +status open + +\begin_layout Plain Layout \begin_inset ERT status collapsed @@ -486,17 +652,15 @@ ecvATwo \end_inset -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -}{ \end_layout \end_inset +\begin_inset Argument 4 +status open + +\begin_layout Plain Layout \begin_inset ERT status collapsed @@ -510,17 +674,15 @@ ecvBOne \end_inset -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -}{ \end_layout \end_inset +\begin_inset Argument 5 +status open + +\begin_layout Plain Layout \begin_inset ERT status collapsed @@ -534,17 +696,15 @@ ecvAOne \end_inset -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -}{ \end_layout \end_inset +\begin_inset Argument 6 +status open + +\begin_layout Plain Layout \begin_inset ERT status collapsed @@ -558,12 +718,6 @@ ecvAOne \end_inset -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -}{ \end_layout \end_inset @@ -607,7 +761,7 @@ Computer skills \end_layout \begin_layout Item -\begin_inset Argument +\begin_inset Argument 1 status collapsed \begin_layout Plain Layout @@ -616,13 +770,12 @@ status collapsed \end_inset -OS -\begin_inset ERT -status collapsed + +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +OS \end_layout \end_inset @@ -631,13 +784,11 @@ Linux, Unix, Windows, administration, Apache, Mailman \end_layout \begin_layout Item -Programming -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +Programming \end_layout \end_inset @@ -650,7 +801,7 @@ Java \end_layout \begin_layout Item -\begin_inset Argument +\begin_inset Argument 1 status collapsed \begin_layout Plain Layout @@ -659,13 +810,12 @@ status collapsed \end_inset -Scientific -\begin_inset ERT -status collapsed + +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +Scientific \end_layout \end_inset @@ -674,17 +824,15 @@ Matlab, Autocad, Abaqus, typography, LaTeX, ConTeXt, Scribus, QuarkXPress \end_layout \begin_layout Item +\begin_inset Argument 2 +status open + +\begin_layout Plain Layout Web \begin_inset space ~ \end_inset design -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -}{ \end_layout \end_inset @@ -697,7 +845,7 @@ Interests \end_layout \begin_layout Item -\begin_inset Argument +\begin_inset Argument 1 status collapsed \begin_layout Plain Layout @@ -706,17 +854,16 @@ status collapsed \end_inset + +\begin_inset Argument 2 +status open + +\begin_layout Plain Layout Adventure \begin_inset space ~ \end_inset sports -\begin_inset ERT -status collapsed - -\begin_layout Plain Layout - -}{ \end_layout \end_inset @@ -728,7 +875,7 @@ I like practicing adventure sports like skiing, rock climbing and scuba \end_layout \begin_layout Item -\begin_inset Argument +\begin_inset Argument 1 status collapsed \begin_layout Plain Layout @@ -737,13 +884,12 @@ status collapsed \end_inset -Travelling -\begin_inset ERT -status collapsed + +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +Travelling \end_layout \end_inset @@ -758,13 +904,11 @@ Publications \end_layout \begin_layout Item -References -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +References \end_layout \end_inset @@ -835,12 +979,11 @@ You can also use BibTeX references: \end_layout \begin_layout Item -\begin_inset ERT -status collapsed +\begin_inset Argument 2 +status open \begin_layout Plain Layout - -}{ +References \end_layout \end_inset diff --git a/lib/layouts/europecv.layout b/lib/layouts/europecv.layout index 358e199795..2887e3d5d6 100644 --- a/lib/layouts/europecv.layout +++ b/lib/layouts/europecv.layout @@ -27,138 +27,295 @@ End Input stdcounters.inc Input stdinsets.inc -Style Section - Margin Dynamic - LatexType Command - LatexName ecvsection - NeedProtect 1 - NextNoIndent 1 - Argument 1 - LabelString "Short Title|S" - Tooltip "The title as it appears in the header" - EndArgument - ParSkip 0.4 - TopSep 1.3 - BottomSep 0.7 - ParSep 0.7 - Align Block - LabelSep xxx - LabelType No_Label - Font - Family Sans - Series Bold +Style Name + Margin Dynamic + LatexType Command + LatexName ecvname + Category FrontMatter + InPreamble 1 + ParSkip 0.4 + LabelSep xx + LabelType Static + LabelString "Name:" + LabelFont + Series Bold + Color Blue EndFont - TocLevel 1 +End + +Style FooterName + CopyStyle Name + LatexName ecvfootername + LabelString "Footer name:" +End + +Style Nationality + CopyStyle Name + LatexName ecvnationality + LabelString "Nationality:" +End + +Style Birthday + CopyStyle Name + LatexName ecvdateofbirth + LabelString "Date of birth:" +End + +Style Address + CopyStyle Name + LatexName ecvaddress + LabelString "Address:" +End + +Style Email + CopyStyle Name + LatexName ecvemail + LabelString "E-mail:" +End + +Style Telephone + CopyStyle Name + LatexName ecvtelephone + LabelString "Telephone:" + Argument 1 + LabelString "Mobile" + Tooltip "Mobile phone number" + EndArgument +End + +Style Gender + CopyStyle Name + LatexName ecvgender + LabelString "Gender:" +End + +Style Fax + CopyStyle Name + LatexName ecvfax + LabelString "Fax:" +End + +Style BeforePicture + CopyStyle Name + LatexName ecvbeforepicture + LabelString "Space before picture:" +End + +Style Picture + CopyStyle Name + LatexName ecvpicture + LabelString "Picture:" + Argument 1 + LabelString "Size" + Tooltip "Size the photo is resized to" + EndArgument +End + +Style AfterPicture + CopyStyle Name + LatexName ecvafterpicture + LabelString "Space after picture:" +End + +Style Page + CopyStyle Name + LatexName ecvpage + LabelString "Page:" +End + +Style Section + Margin Dynamic + LatexType Command + LatexName ecvsection + Category MainText + NeedProtect 1 + NextNoIndent 1 + Argument 1 + LabelString "Short Title|S" + Tooltip "The title as it appears in the header" + EndArgument + ParSkip 0.4 + TopSep 1.3 + BottomSep 0.7 + ParSep 0.7 + Align Block + LabelSep xxx + LabelType No_Label + Font + Family Sans + Series Bold + EndFont + TocLevel 1 End Style Item - Margin Dynamic - LatexType Command - LatexName ecvitem + Margin Dynamic + LatexType Command + LatexName ecvitem + Category MainText Argument 1 - LabelString "Vertical Space (Item)|S" - Tooltip "Adjust the vertical space of this item" + LabelString "Vertical Space" + Tooltip "Additional vertical space" EndArgument - ParSkip 0.4 - Align Block - LabelSep xx - LabelType Static - LabelString "Item:" + Argument 2 + Mandatory 1 + LabelString "Summary" + Tooltip "Summary of the item, can also be the time" + EndArgument + ParSkip 0.4 + Align Block + LabelSep xx + LabelType Static + LabelString "Item:" LabelFont - Series Bold - Color Blue + Series Bold + Color Blue EndFont End Style BulletedItem - CopyStyle Item - LatexName ecvitem* - LabelString "Bulleted Item:" + CopyStyle Item + LatexName ecvitem* + LabelString "Bulleted Item:" End Style Begin - Margin Dynamic - LatexType Command - LatexName begin{europecv} - KeepEmpty 1 - BottomSep 1 - ParSkip 0.4 - Align Block - LabelSep xx - LabelType Static - LabelString "Begin of CV" + Margin Dynamic + LatexType Command + LatexName begin{europecv} + Category FrontMatter + KeepEmpty 1 + TopSep 1 + BottomSep 1 + ParSkip 0.4 + Align Block + LabelSep xx + LabelType Static + LabelString "Begin of CV" LabelFont - Series Bold - Color Green + Series Bold + Color Green EndFont End Style PersonalInfo - CopyStyle Begin - LatexName ecvpersonalinfo{} - BottomSep 0 - LabelString "Personal Info" + CopyStyle Begin + LatexName ecvpersonalinfo{} + TopSep 0 + BottomSep 0 + LabelString "Personal Info" End Style MotherTongue - Margin Dynamic - LatexType Command - LatexName ecvmothertongue + Margin Dynamic + LatexType Command + LatexName ecvmothertongue + Category MainText Argument 1 - LabelString "Vertical Space (Item)|S" - Tooltip "Adjust the vertical space of this item" + LabelString "Vertical Space" + Tooltip "Additional vertical space" EndArgument - ParSkip 0.4 - Align Block - LabelSep xx - LabelType Static - LabelString "Mother Tongue:" + ParSkip 0.4 + Align Block + LabelSep xx + LabelType Static + LabelString "Mother Tongue:" + Font + Series Bold + EndFont LabelFont - Series Bold - Color Blue + Series Bold + Color Blue EndFont End Style LangHeader - CopyStyle MotherTongue - LatexName ecvlanguageheader - ResetArgs 1 - LabelString "Language Header:" + CopyStyle MotherTongue + LatexName ecvlanguageheader + ResetArgs 1 + LabelString "Language Header:" End Style Language - CopyStyle MotherTongue - LatexName ecvlanguage - LabelString "Language:" + CopyStyle MotherTongue + LatexName ecvlanguage + LabelString "Language:" + Argument 2 + Mandatory 1 + LabelString "Language" + Tooltip "Name of the language" + EndArgument + Argument 3 + Mandatory 1 + LabelString "Listening" + Tooltip "Level how good you think you can listen" + EndArgument + Argument 4 + Mandatory 1 + LabelString "Reading" + Tooltip "Level how good you think you can read" + EndArgument + Argument 5 + Mandatory 1 + LabelString "Interaction" + Tooltip "Level how good you think you can conversate" + EndArgument + Argument 6 + Mandatory 1 + LabelString "Production" + Tooltip "Level how good you think you can freely talk" + EndArgument End Style LastLanguage - CopyStyle MotherTongue - LatexName ecvlastlanguage - LabelString "Last Language:" + CopyStyle Language + LatexName ecvlastlanguage + LabelString "Last Language:" End Style LangFooter - CopyStyle MotherTongue - LatexName ecvlanguagefooter - ResetArgs 1 - LabelString "Language Footer:" + CopyStyle LangHeader + LatexName ecvlanguagefooter + LabelString "Language Footer:" End Style End - Margin Dynamic - LatexType Command - LatexName end{europecv} - KeepEmpty 1 - TopSep 1 - ParSkip 0.4 - Align Block - LabelSep xx - LabelType Static - LabelString "End of CV" + Margin Dynamic + LatexType Command + LatexName end{europecv} + Category BackMatter + KeepEmpty 1 + TopSep 1 + ParSkip 0.4 + Align Block + LabelSep xx + LabelType Static + LabelString "End of CV" LabelFont - Series Bold - Color Green + Series Bold + Color Green + EndFont +End + +InsetLayout "Flex:VerticalSpace" + LyxType custom + LatexType command + LatexName ecvspace + Decoration Conglomerate + LabelString "Vertical space" + Font + Color foreground + Size Small + Family Roman + Shape Up + Series Medium + Misc No_Emph + Misc No_Noun + Misc No_Bar + EndFont + LabelFont + Color green + Size Small EndFont End diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index e7b7c6ef27..c95fec46fa 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -1373,7 +1373,8 @@ def revert_IEEEtran(document): def convert_TeX_brace_to_Argument(document, line, n, nmax, inset, environment): ''' - Converts TeX code to an InsetArgument + Converts TeX code for mandatory arguments to an InsetArgument + The conversion of TeX code for optional arguments must be done with another routine !!! Be careful if the braces are different in your case as expected here: - "}{" separates mandatory arguments of commands - "}" + "{" separates mandatory arguments of commands @@ -1387,18 +1388,36 @@ def convert_TeX_brace_to_Argument(document, line, n, nmax, inset, environment): isInset must be true, if braces inside an InsetLayout needs to be converted isEnvironment must be true, if the layout is for a LaTeX environment - Note: this routine can currently handle only one mandatory argument of environments + Todo: this routine can currently handle only one mandatory argument of environments ''' - lineArg = line - while lineArg != -1 and n < nmax + 1: - lineArg = find_token(document.body, "\\begin_inset ERT", lineArg) - if environment == False and lineArg != -1: - bracePair = find_token(document.body, "}{", lineArg) + lineERT = line + endn = line + loop = 1 + while lineERT != -1 and n < nmax + 1: + lineERT = find_token(document.body, "\\begin_inset ERT", lineERT) + if environment == False and lineERT != -1: + bracePair = find_token(document.body, "}{", lineERT) # assure that the "}{" is in this ERT - if bracePair == lineArg + 5: + if bracePair == lineERT + 5: end = find_token(document.body, "\\end_inset", bracePair) - document.body[lineArg : end + 1] = ["\\end_layout", "", "\\end_inset"] - if n == 1: + document.body[lineERT : end + 1] = ["\\end_layout", "", "\\end_inset"] + if loop == 1: + # in the case that n > 1 we have optional arguments before + # therefore detect them if any + if n > 1: + # first check if there is an argument + lineArg = find_token(document.body, "\\begin_inset Argument", line) + if lineArg < lineERT and lineArg != -1: + # we have an argument, so now search backwards for its end + # we must now assure that we don't find other insets like e.g. a newline + endInsetArg = lineERT + endLayoutArg = endInsetArg + while endInsetArg != endLayoutArg + 2 and endInsetArg != -1: + endInsetArg = endInsetArg - 1 + endLayoutArg = endInsetArg + endInsetArg = find_token_backwards(document.body, "\\end_inset", endInsetArg) + endLayoutArg = find_token_backwards(document.body, "\\end_layout", endLayoutArg) + line = endInsetArg + 1 if inset == False: document.body[line + 1 : line + 1] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"] else: @@ -1407,16 +1426,33 @@ def convert_TeX_brace_to_Argument(document, line, n, nmax, inset, environment): document.body[endn : endn] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"] n = n + 1 endn = end + loop = loop + 1 # now check the case that we have "}" + "{" in two ERTs else: - endBrace = find_token(document.body, "}", lineArg) - if endBrace == lineArg + 5: + endBrace = find_token(document.body, "}", lineERT) + if endBrace == lineERT + 5: beginBrace = find_token(document.body, "{", endBrace) # assure that the ERTs are consecutive (11 or 12 depending if there is a space between the ERTs or not) if beginBrace == endBrace + 11 or beginBrace == endBrace + 12: end = find_token(document.body, "\\end_inset", beginBrace) - document.body[lineArg : end + 1] = ["\\end_layout", "", "\\end_inset"] - if n == 1: + document.body[lineERT : end + 1] = ["\\end_layout", "", "\\end_inset"] + if loop == 1: + # in the case that n > 1 we have optional arguments before + # therefore detect them if any + if n > 1: + # first check if there is an argument + lineArg = find_token(document.body, "\\begin_inset Argument", line) + if lineArg < lineERT and lineArg != -1: + # we have an argument, so now search backwards for its end + # we must now assure that we don't find other insets like e.g. a newline + endInsetArg = lineERT + endLayoutArg = endInsetArg + while endInsetArg != endLayoutArg + 2 and endInsetArg != -1: + endInsetArg = endInsetArg - 1 + endLayoutArg = endInsetArg + endInsetArg = find_token_backwards(document.body, "\\end_inset", endInsetArg) + endLayoutArg = find_token_backwards(document.body, "\\end_layout", endLayoutArg) + line = endInsetArg + 1 if inset == False: document.body[line + 1 : line + 1] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"] else: @@ -1424,26 +1460,27 @@ def convert_TeX_brace_to_Argument(document, line, n, nmax, inset, environment): else: document.body[endn : endn] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"] n = n + 1 + loop = loop + 1 # set the line where the next argument will be inserted if beginBrace == endBrace + 11: endn = end - 11 else: endn = end - 12 else: - lineArg = lineArg + 1 - if environment == True and lineArg != -1: - opening = find_token(document.body, "{", lineArg) - if opening == lineArg + 5 or opening == lineArg + 4: # assure that the "{" is in this ERT + lineERT = lineERT + 1 + if environment == True and lineERT != -1: + opening = find_token(document.body, "{", lineERT) + if opening == lineERT + 5: # assure that the "{" is in this ERT end = find_token(document.body, "\\end_inset", opening) - document.body[lineArg : end + 1] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"] + document.body[lineERT : end + 1] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"] n = n + 1 - lineArg2 = find_token(document.body, "\\begin_inset ERT", lineArg) - closing = find_token(document.body, "}", lineArg2) - if closing == lineArg2 + 5 or closing == lineArg2 + 4: # assure that the "}" is in this ERT + lineERT2 = find_token(document.body, "\\begin_inset ERT", lineERT) + closing = find_token(document.body, "}", lineERT2) + if closing == lineERT2 + 5: # assure that the "}" is in this ERT end2 = find_token(document.body, "\\end_inset", closing) - document.body[lineArg2 : end2 + 1] = ["\\end_layout", "", "\\end_inset"] + document.body[lineERT2 : end2 + 1] = ["\\end_layout", "", "\\end_inset"] else: - lineArg = lineArg + 1 + lineERT = lineERT + 1 def convert_IEEEtran(document): @@ -1636,6 +1673,70 @@ def convert_SIGGRAPH(document): return +def revert_EuropeCV(document): + " Reverts InsetArgument of Flex CRcat to TeX-code " + if document.textclass == "europecv": + i = 0 + j = 0 + k = 0 + m = 0 + while True: + if i != -1: + i = find_token(document.body, "\\begin_layout Item", i) + if i != -1: + revert_Argument_to_TeX_brace(document, i, 2, 2, False) + i = i + 1 + if j != -1: + j = find_token(document.body, "\\begin_layout BulletedItem", j) + if j != -1: + revert_Argument_to_TeX_brace(document, j, 2, 2, False) + j = j + 1 + if k != -1: + k = find_token(document.body, "\\begin_layout Language", k) + if k != -1: + revert_Argument_to_TeX_brace(document, k, 2, 6, False) + k = k + 1 + if m != -1: + m = find_token(document.body, "\\begin_layout LastLanguage", m) + if m != -1: + revert_Argument_to_TeX_brace(document, m, 2, 6, False) + m = m + 1 + if i == -1 and j == -1 and k == -1 and m == -1: + return + + +def convert_EuropeCV(document): + " Converts ERT of Flex CRcat to InsetArgument " + if document.textclass == "europecv": + i = 0 + j = 0 + k = 0 + m = 0 + while True: + if i != -1: + i = find_token(document.body, "\\begin_layout Item", i) + if i != -1: + convert_TeX_brace_to_Argument(document, i, 2, 2, False, False) + i = i + 1 + if j != -1: + j = find_token(document.body, "\\begin_layout BulletedItem", j) + if j != -1: + convert_TeX_brace_to_Argument(document, j, 2, 2, False, False) + j = j + 1 + if k != -1: + k = find_token(document.body, "\\begin_layout Language", k) + if k != -1: + convert_TeX_brace_to_Argument(document, k, 2, 6, False, False) + k = k + 1 + if m != -1: + m = find_token(document.body, "\\begin_layout LastLanguage", m) + if m != -1: + convert_TeX_brace_to_Argument(document, m, 2, 6, False, False) + m = m + 1 + if i == -1 and j == -1 and k == -1 and m == -1: + return + + def revert_literate(document): " Revert Literate document to old format " if del_token(document.header, "noweb", 0): @@ -1733,7 +1834,7 @@ convert = [ [444, []], [445, []], [446, [convert_latexargs]], - [447, [convert_IEEEtran, convert_AASTeX, convert_AGUTeX, convert_IJMP, convert_SIGPLAN, convert_SIGGRAPH]], + [447, [convert_IEEEtran, convert_AASTeX, convert_AGUTeX, convert_IJMP, convert_SIGPLAN, convert_SIGGRAPH, convert_EuropeCV]], [448, [convert_literate]], [449, []] ] @@ -1741,7 +1842,7 @@ convert = [ revert = [ [448, [revert_itemargs]], [447, [revert_literate]], - [446, [revert_IEEEtran, revert_AASTeX, revert_AGUTeX, revert_IJMP, revert_SIGPLAN, revert_SIGGRAPH]], + [446, [revert_IEEEtran, revert_AASTeX, revert_AGUTeX, revert_IJMP, revert_SIGPLAN, revert_SIGGRAPH, revert_EuropeCV]], [445, [revert_latexargs]], [444, [revert_uop]], [443, [revert_biolinum]],