Am Donnerstag, 2. Februar 2006 12:09 schrieb Juergen Spitzmueller: > It works for me except for one drawback: the content of branches is always > placed in a new paragraph, even if the branch was inline. If it is easy to > fix, I'd appreciate that, since I use branches almost always inline.
This was an oversight by me. The attached patch does not create these new paragraphs, and it also does not create empty new paragraphs. The reason for both problems was the line '\layout' that is always at the beginning of a branch inset but does not correspond to a paragraph break in .tex output. Lars, Jean-Marc: Can this go in? Georg
Index: development/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/development/ChangeLog,v retrieving revision 1.65 diff -u -p -r1.65 ChangeLog --- development/ChangeLog 1 Feb 2006 15:16:59 -0000 1.65 +++ development/ChangeLog 1 Feb 2006 21:00:12 -0000 @@ -1,3 +1,7 @@ +2006-02-02 Georg Baum <[EMAIL PROTECTED]> + + * FORMAT: document branches + 2006-02-01 Bennett Helm <[EMAIL PROTECTED]> * MacOSX/LyX.app/Contents/Resources/preferences: update again. Index: development/FORMAT =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/development/FORMAT,v retrieving revision 1.43 diff -u -p -r1.43 FORMAT --- development/FORMAT 13 Oct 2005 10:59:36 -0000 1.43 +++ development/FORMAT 1 Feb 2006 21:00:13 -0000 @@ -296,6 +296,26 @@ Paragraph text. * attribute valignment="center" is replaced by valignment="middle" for tabular columns and cells +2003-08-17 Martin Vermeer <[EMAIL PROTECTED]> + + * Added branch inset. File format: + + branch definition in the header: + \branch <branchname> + \selected 0 0/1 + \color #rrggbb + \end_branch + + \begin_inset Branch <branchname> + collapsed false true/false + + \begin_layout Standard + + <branch contents> + \end_layout + + \end_inset + 2003-07-28 José Matos <[EMAIL PROTECTED]> * \the_end is replaced with \end_document Index: lib/lyx2lyx/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/ChangeLog,v retrieving revision 1.106 diff -u -p -r1.106 ChangeLog --- lib/lyx2lyx/ChangeLog 1 Dec 2005 19:00:06 -0000 1.106 +++ lib/lyx2lyx/ChangeLog 1 Feb 2006 21:00:13 -0000 @@ -1,3 +1,7 @@ +2006-02-02 Georg Baum <[EMAIL PROTECTED]> + + * lyx_1_4.py (remove_branches): new, remove branch insets + 2005-12-01 José Matos <[EMAIL PROTECTED]> * LyX.py (choose_io): replace open and make the choice more transparent. Index: lib/lyx2lyx/lyx_1_4.py =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/lyx_1_4.py,v retrieving revision 1.55 diff -u -p -r1.55 lyx_1_4.py --- lib/lyx2lyx/lyx_1_4.py 21 Nov 2005 17:05:03 -0000 1.55 +++ lib/lyx2lyx/lyx_1_4.py 2 Feb 2006 18:06:08 -0000 @@ -1613,6 +1613,51 @@ def convert_frameless_box(file): 'collapsed ' + params['collapsed']] i = i + 6 + +def remove_branches(file): + i = 0 + while 1: + i = find_token(file.header, "\\branch", i) + if i == -1: + break + file.warning("Removing branch %s." % split(file.header[i])[1]) + j = find_token(file.header, "\\end_branch", i) + if j == -1: + file.warning("Malformed LyX file: Missing '\\end_branch'.") + break + del file.header[i:j+1] + + i = 0 + while 1: + i = find_token(file.body, "\\begin_inset Branch", i) + if i == -1: + return + j = find_end_of_inset(file.body, i) + if j == -1: + file.warning("Malformed LyX file: Missing '\\end_inset'.") + i = i + 1 + continue + del file.body[i] + del file.body[j - 1] + # Seach for a line starting 'collapsed' + # If, however, we find a line starting '\layout' + # (_always_ present) then break with a warning message + collapsed_found = 0 + while 1: + if (file.body[i][:9] == "collapsed"): + del file.body[i] + collapsed_found = 1 + continue + elif (file.body[i][:7] == "\\layout"): + if collapsed_found == 0: + file.warning("Malformed LyX file: Missing 'collapsed'.") + # Delete this new paragraph, since it would not appear in + # .tex output. This avoids also empty paragraphs. + del file.body[i] + break + i = i + 1 + + ## # Convert jurabib # @@ -2318,7 +2447,8 @@ revert = [[244, []], [226, [revert_box, revert_external_2]], [225, [revert_note]], [224, [rm_end_layout, begin_layout2layout, revert_end_document, - revert_valignment_middle, revert_breaks, convert_frameless_box]], + revert_valignment_middle, revert_breaks, convert_frameless_box, + remove_branches]], [223, [revert_external_2, revert_comment, revert_eqref]], [222, [revert_spaces, revert_bibtex]], [221, [rm_end_header, rm_tracking_changes, rm_body_changes]]]