From 6c0bc842b75d7687f0c2554ebd80c9035758097c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Wed, 29 May 2013 01:11:14 +0200 Subject: [PATCH] moderncv.layout: support the command \social - \social can be used for social network addresses in the address block --- lib/examples/modernCV.lyx | 61 +++++++++++++++++++++++++++++++++++++ lib/layouts/moderncv.layout | 10 ++++++ lib/lyx2lyx/lyx_2_1.py | 35 +++++++++++++++++++-- 3 files changed, 104 insertions(+), 2 deletions(-) diff --git a/lib/examples/modernCV.lyx b/lib/examples/modernCV.lyx index 5138a2176e..46962907f4 100644 --- a/lib/examples/modernCV.lyx +++ b/lib/examples/modernCV.lyx @@ -260,6 +260,67 @@ testman@testman.xx www.johndoe.com \end_layout +\begin_layout Social +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +twitter +\end_layout + +\end_inset + +ptestman +\begin_inset Note Note +status open + +\begin_layout Plain Layout +currently only +\series bold +twitter +\series default +, +\series bold +linkedin +\series default + or +\series bold +github +\series default + is supported as name +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Social +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +linkedin +\end_layout + +\end_inset + +ptestman +\end_layout + +\begin_layout Social +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +github +\end_layout + +\end_inset + +ptestman +\end_layout + \begin_layout ExtraInfo www.lyx.org \end_layout diff --git a/lib/layouts/moderncv.layout b/lib/layouts/moderncv.layout index 7512e3fa02..8dcdcf5cfd 100644 --- a/lib/layouts/moderncv.layout +++ b/lib/layouts/moderncv.layout @@ -152,6 +152,16 @@ Style Homepage LabelString "Homepage:" End +Style Social + CopyStyle CVStyle + LatexName social + LabelString "Social:" + Argument 1 + LabelString "Name" + Tooltip "Name of the social network" + EndArgument +End + Style ExtraInfo CopyStyle CVStyle LatexName extrainfo diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index 59c81420ec..0c38796f6f 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -1872,6 +1872,7 @@ def revert_ModernCV(document): k = 0 m = 0 o = 0 + p = 0 while True: if j != -1: j = find_token(document.body, "\\begin_layout Entry", j) @@ -1895,7 +1896,12 @@ def revert_ModernCV(document): revert_Argument_to_TeX_brace(document, o, 0, 1, 3, False, False) document.body[o] = document.body[o].replace("\\begin_layout DoubleItem", "\\begin_layout Computer") o = o + 1 - if j == -1 and k == -1 and m == -1 and o == -1: + if p != -1: + p = find_token(document.body, "\\begin_layout Social", p) + if p != -1: + revert_Argument_to_TeX_brace(document, p, 0, 1, 1, False, True) + p = p + 1 + if j == -1 and k == -1 and m == -1 and o == -1 and p == -1: return @@ -1944,6 +1950,31 @@ def revert_ModernCV_3(document): return +def revert_ModernCV_4(document): + " Reverts the style Social to TeX-code " + if document.textclass == "moderncv": + # revert the layouts + revert_ModernCV(document) + p = 0 + while True: + if p != -1: + p = find_token(document.body, "\\begin_layout Social", p) + if p != -1: + pEnd = find_end_of_layout(document.body, p) + document.body[p] = document.body[p].replace("\\begin_layout Social", "\\begin_layout Standard") + document.body[p + 1 : p + 1] = put_cmd_in_ert("\\social") + hasOpt = find_token(document.body, "[", p + 9) + if hasOpt < p + 18: + document.body[p + 30 : p + 30] = put_cmd_in_ert("{") + document.body[p + 41 : p + 41] = put_cmd_in_ert("}") + else: + document.body[p + 11 : p + 11] = put_cmd_in_ert("{") + document.body[p + 21 : p + 21] = put_cmd_in_ert("}") + p = p + 1 + if p == -1: + return + + def convert_ModernCV(document): " Converts ERT of modernCV to InsetArgument " if document.textclass == "moderncv": @@ -4293,7 +4324,7 @@ revert = [ [449, [revert_garamondx, revert_garamondx_newtxmath]], [448, [revert_itemargs]], [447, [revert_literate]], - [446, [revert_IEEEtran, revert_IEEEtran_2, revert_AASTeX, revert_AGUTeX, revert_IJMP, revert_SIGPLAN, revert_SIGGRAPH, revert_EuropeCV, revert_Initials, revert_ModernCV_3]], + [446, [revert_IEEEtran, revert_IEEEtran_2, revert_AASTeX, revert_AGUTeX, revert_IJMP, revert_SIGPLAN, revert_SIGGRAPH, revert_EuropeCV, revert_Initials, revert_ModernCV_3, revert_ModernCV_4]], [445, [revert_latexargs]], [444, [revert_uop]], [443, [revert_biolinum]], -- 2.39.2