On Fri, Aug 17, 2007 at 06:54:25PM +0300, Martin Vermeer wrote:
> On Thu, Aug 16, 2007 at 07:11:33PM +0300, Martin Vermeer wrote:
> > On Thu, Aug 16, 2007 at 03:58:44PM +0200, Jean-Marc Lasgouttes wrote:
> 
> ...
>  
> > Shall I for now just give "long names" to the charstyles
> > in the layout file, like CharStyle:Noun?
> 
> The patch, and its lyx2lyx counterpart, are committed 
> (but the development/FORMAT file again forgotten :-( )
> 
> > We need a layout2layout conversion too:
> > 
> > CharStyle noun
> >   ...
> > 
> > should be transformed to
> > 
> > InsetLayout CharStyle:Noun
> >   LyxType   charstyle
> >   LabelString   noun
> >   ...
> 
> Next thing on the list.

Attached my attempt. I am a complete amateur with python
and work with layout2layout also for the first time, so...
does this make sense? FWIW it works.

- Martin
 
  
Index: layout2layout.py
===================================================================
--- layout2layout.py    (revision 19567)
+++ layout2layout.py    (working copy)
@@ -80,6 +80,7 @@
     re_NoStyle = re.compile(r'^(\s*)(NoStyle)(\s+)(\S+)', re.IGNORECASE)
     re_End = re.compile(r'^(\s*)(End)(\s*)$', re.IGNORECASE)
     re_Provides = re.compile(r'^(\s*)Provides(\S+)(\s+)(\S+)', re.IGNORECASE)
+    re_CharStyle = re.compile(r'^(\s*)CharStyle(\s+)(\S+)$', re.IGNORECASE)
 
     # counters for sectioning styles (hardcoded in 1.3)
     counters = {"part"          : "\\Roman{part}",
@@ -134,10 +135,10 @@
                 match = re_Format.match(lines[i])
                 if match:
                         format = int(match.group(4))
-                        if format > 1 and format < 4:
+                        if format > 1 and format < 5:
                             lines[i] = "Format %d" % (format + 1)
                             only_comment = 0
-                        elif format == 4:
+                        elif format == 5:
                                 # nothing to do
                                 return format
                         else:
@@ -154,6 +155,19 @@
                 i = i + 1
             continue
 
+        if format == 4:
+            # Handle conversion to long CharStyle names
+            match = re_CharStyle.match(lines[i])
+            if match:
+                lines[i] = "InsetLayout CharStyle:%s" % (match.group(3))
+                i = i + 1
+                lines.insert(i, "\tLyXType charstyle")
+                i = i + 1
+                lines.insert(i, "")
+                lines[i] = "\tLabelString %s" % (match.group(3))
+            i = i + 1
+            continue
+
         if format == 3:
             # convert 'providesamsmath x',  'providesmakeidx x',  
'providesnatbib x',  'providesurl x' to
             #         'provides amsmath x', 'provides makeidx x', 'provides 
natbib x', 'provides url x'

Reply via email to