mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
lyx2lyx: Use correct check for emty lines while converting Begin/EndFrontmatter
* Coversion now tries not to pollute the result with emty lines * stripped some trailing spaces
This commit is contained in:
parent
d70468a3b2
commit
7f3fd5a809
@ -64,22 +64,30 @@ def removeFrontMatterStyles(document):
|
||||
document.warning("Malformed LyX document: Can't find end of layout at line %d" % i)
|
||||
i += 1
|
||||
continue
|
||||
if document.body[j] == '':
|
||||
while i > 0 and document.body[i-1].strip() == '':
|
||||
i -= 1
|
||||
while document.body[j+1].strip() == '':
|
||||
j = j + 1
|
||||
del document.body[i:j+1]
|
||||
document.body[i:j+1] = ['']
|
||||
|
||||
def addFrontMatterStyles(document):
|
||||
" Use styles Begin/EndFrontmatter for elsarticle"
|
||||
|
||||
def insertFrontmatter(prefix, line):
|
||||
document.body[line:line] = ['\\begin_layout ' + prefix + 'Frontmatter',
|
||||
above = line
|
||||
while above > 0 and document.body[above-1].strip() == '':
|
||||
above -= 1
|
||||
below = line
|
||||
while document.body[below].strip() == '':
|
||||
below += 1
|
||||
document.body[above:below] = ['', '\\begin_layout ' + prefix + 'Frontmatter',
|
||||
'\\begin_inset Note Note',
|
||||
'status open', '',
|
||||
'\\begin_layout Plain Layout',
|
||||
'Keep this empty!',
|
||||
'\\end_layout', '',
|
||||
'\\end_inset', '', '',
|
||||
'\\end_layout']
|
||||
'\\end_layout', '']
|
||||
|
||||
if document.textclass == "elsarticle":
|
||||
layouts = ['Title', 'Title footnote', 'Author', 'Author footnote',
|
||||
@ -101,13 +109,9 @@ def addFrontMatterStyles(document):
|
||||
first = i
|
||||
if last == -1 or last <= k:
|
||||
last = k+1
|
||||
i = k
|
||||
i = k+1
|
||||
if first == -1:
|
||||
return
|
||||
if first > 0 and document.body[first-1] == '':
|
||||
first -= 1
|
||||
if document.body[last] == '':
|
||||
last = last + 1
|
||||
insertFrontmatter('End', last)
|
||||
insertFrontmatter('Begin', first)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user