i += 1
+def convert_flexnames(document):
+ "Convert \\begin_inset Flex Custom:Style to \\begin_inset Flex Style and similarly for CharStyle and Element."
+
+ i = 0
+ rx = re.compile(r'^\\begin_inset Flex (?:Custom|CharStyle|Element):(.+)$')
+ while True:
+ i = find_token(document.body, "\\begin_inset Flex", i)
+ if i == -1:
+ return
+ m = rx.match(document.body[i])
+ if m:
+ document.body[i] = "\\begin_inset Flex " + m.group(1)
+ i += 1
+
+
+flex_insets = [
+ ["Alert", "CharStyle:Alert"],
+ ["Code", "CharStyle:Code"],
+ ["Concepts", "CharStyle:Concepts"],
+ ["E-Mail", "CharStyle:E-Mail"],
+ ["Emph", "CharStyle:Emph"],
+ ["Expression", "CharStyle:Expression"],
+ ["Initial", "CharStyle:Initial"],
+ ["Institute", "CharStyle:Institute"],
+ ["Meaning", "CharStyle:Meaning"],
+ ["Noun", "CharStyle:Noun"],
+ ["Strong", "CharStyle:Strong"],
+ ["Structure", "CharStyle:Structure"],
+ ["ArticleMode", "Custom:ArticleMode"],
+ ["Endnote", "Custom:Endnote"],
+ ["Glosse", "Custom:Glosse"],
+ ["PresentationMode", "Custom:PresentationMode"],
+ ["Tri-Glosse", "Custom:Tri-Glosse"]
+]
+
+flex_elements = [
+ ["Abbrev", "Element:Abbrev"],
+ ["CCC-Code", "Element:CCC-Code"],
+ ["Citation-number", "Element:Citation-number"],
+ ["City", "Element:City"],
+ ["Code", "Element:Code"],
+ ["CODEN", "Element:CODEN"],
+ ["Country", "Element:Country"],
+ ["Day", "Element:Day"],
+ ["Directory", "Element:Directory"],
+ ["Dscr", "Element:Dscr"],
+ ["Email", "Element:Email"],
+ ["Emph", "Element:Emph"],
+ ["Filename", "Element:Filename"],
+ ["Firstname", "Element:Firstname"],
+ ["Fname", "Element:Fname"],
+ ["GuiButton", "Element:GuiButton"],
+ ["GuiMenu", "Element:GuiMenu"],
+ ["GuiMenuItem", "Element:GuiMenuItem"],
+ ["ISSN", "Element:ISSN"],
+ ["Issue-day", "Element:Issue-day"],
+ ["Issue-months", "Element:Issue-months"],
+ ["Issue-number", "Element:Issue-number"],
+ ["KeyCap", "Element:KeyCap"],
+ ["KeyCombo", "Element:KeyCombo"],
+ ["Keyword", "Element:Keyword"],
+ ["Literal", "Element:Literal"],
+ ["MenuChoice", "Element:MenuChoice"],
+ ["Month", "Element:Month"],
+ ["Orgdiv", "Element:Orgdiv"],
+ ["Orgname", "Element:Orgname"],
+ ["Postcode", "Element:Postcode"],
+ ["SS-Code", "Element:SS-Code"],
+ ["SS-Title", "Element:SS-Title"],
+ ["State", "Element:State"],
+ ["Street", "Element:Street"],
+ ["Surname", "Element:Surname"],
+ ["Volume", "Element:Volume"],
+ ["Year", "Element:Year"]
+]
+
+
+def revert_flexnames(document):
+ if document.backend == "latex":
+ flexlist = flex_insets
+ else:
+ flexlist = flex_elements
+
+ rx = re.compile(r'^\\begin_inset Flex\s+(.+)$')
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_inset Flex", i)
+ if i == -1:
+ return
+ m = rx.match(document.body[i])
+ if not m:
+ document.warning("Illegal flex inset: " + document.body[i])
+ i += 1
+ continue
+
+ style = m.group(1)
+ for f in flexlist:
+ if f[0] == style:
+ document.body[i] = "\\begin_inset Flex " + f[1]
+ break
+
+ i += 1
+
+
def convert_mathdots(document):
" Load mathdots automatically "
while True:
[399, [convert_mathdots]],
[400, [convert_rule]],
[401, []],
- [402, [convert_bibtexClearpage]]
- ]
+ [402, [convert_bibtexClearpage]],
+ [403, [convert_flexnames]]
+]
-revert = [[401, []],
+revert = [[402, [revert_flexnames]],
+ [401, []],
[400, [revert_diagram]],
[399, [revert_rule]],
[398, [revert_mathdots]],
# Incremented to format 28, 6 August 2010 by lasgouttes
# Added ParbreakIsNewline tag for Layout and InsetLayout.
+# Incremented to format 29, 10 August 2010 by rgh
+# Changed Custom:Style, CharStyle:Style, and Element:Style
+# uniformly to Flex:Style.
+
# Do not forget to document format change in Customization
# Manual (section "Declaring a new text class").
# development/tools/updatelayouts.sh script to update all
# layout files to the new format.
-currentFormat = 28
+currentFormat = 29
def usage(prog_name):
re_Type = re.compile(r'\s*Type\s+(\w+)', re.IGNORECASE)
re_Builtin = re.compile(r'^(\s*)LaTeXBuiltin\s+(\w*)', re.IGNORECASE)
re_True = re.compile(r'^\s*(?:true|1)\s*$', re.IGNORECASE)
+ re_InsetLayout = re.compile(r'^\s*InsetLayout\s+(?:Custom|CharStyle|Element):(\S+)\s*$')
+ # with quotes
+ re_QInsetLayout = re.compile(r'^\s*InsetLayout\s+"(?:Custom|CharStyle|Element):([^"]+)"\s*$')
# counters for sectioning styles (hardcoded in 1.3)
counters = {"part" : "\\Roman{part}",
i += 1
continue
+ if format == 28:
+ match = re_InsetLayout.match(lines[i])
+ if match:
+ lines[i] = "InsetLayout Flex:" + match.group(1)
+ else:
+ match = re_QInsetLayout.match(lines[i])
+ if match:
+ lines[i] = "InsetLayout \"Flex:" + match.group(1) + "\""
+ i += 1
+ continue
+
# Only new features
if format >= 24 and format <= 27:
- i += 1
- continue
+ i += 1
+ continue
if format == 23:
match = re_Float.match(lines[i])