mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
Adapt lyx2lyx to the lineno support fix in [88f471899/lyxgit].
This commit is contained in:
parent
2ea92342b7
commit
45c5b39692
@ -1698,34 +1698,31 @@ def revert_utf8_japanese(document):
|
|||||||
def revert_lineno(document):
|
def revert_lineno(document):
|
||||||
" Replace lineno setting with user-preamble code."
|
" Replace lineno setting with user-preamble code."
|
||||||
|
|
||||||
|
options = get_quoted_value(document.header, "\\lineno_options",
|
||||||
|
delete=True)
|
||||||
if not get_bool_value(document.header, "\\use_lineno", delete=True):
|
if not get_bool_value(document.header, "\\use_lineno", delete=True):
|
||||||
return
|
return
|
||||||
lineno_options = get_quoted_value(document.header, "\\lineno_options",
|
if options:
|
||||||
delete=True)
|
options = "[" + options + "]"
|
||||||
if lineno_options:
|
add_to_preamble(document, ["\\usepackage%s{lineno}" % options,
|
||||||
usepkg = "\\usepackage[%s]{lineno}"%lineno_options
|
"\\linenumbers"])
|
||||||
else:
|
|
||||||
usepkg = "\\usepackage{lineno}"
|
|
||||||
add_to_preamble(document, [usepkg, "\\linenumbers"])
|
|
||||||
|
|
||||||
def convert_lineno(document):
|
def convert_lineno(document):
|
||||||
" Replace user-preamble code with native lineno support."
|
" Replace user-preamble code with native lineno support."
|
||||||
|
use_lineno = 0
|
||||||
|
options = ""
|
||||||
j = find_token(document.preamble, "\\linenumbers", 1)
|
j = find_token(document.preamble, "\\linenumbers", 1)
|
||||||
if j == -1:
|
if j > -1:
|
||||||
return
|
usepkg = re.match(r"\\usepackage(.*){lineno}", document.preamble[j-1])
|
||||||
usepkg = re.match(r"\\usepackage(.*){lineno}", document.preamble[j-1])
|
if usepkg:
|
||||||
if usepkg is None:
|
use_lineno = 1
|
||||||
return
|
options = usepkg.group(1).strip("[]")
|
||||||
options = usepkg.group(1).strip("[]")
|
del(document.preamble[j-1:j+1])
|
||||||
|
del_token(document.preamble, "% Added by lyx2lyx", j-2, j-1)
|
||||||
del(document.preamble[j-1:j+1])
|
|
||||||
print (j, document.preamble[j-2])
|
|
||||||
del_token(document.preamble, "% Added by lyx2lyx", j-2, j-1)
|
|
||||||
|
|
||||||
k = find_token(document.header, "\\index ")
|
k = find_token(document.header, "\\index ")
|
||||||
document.header.insert(k, "\\use_lineno 1")
|
document.header[k:k] = ["\\use_lineno %d" % use_lineno,
|
||||||
if options:
|
"\\lineno_options %s" % options]
|
||||||
document.header.insert(k+1 or -1, '\\lineno_options %s'%options)
|
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#LyX file created by tex2lyx 2.4
|
#LyX file created by tex2lyx 2.4
|
||||||
\lyxformat 574
|
\lyxformat 575
|
||||||
\begin_document
|
\begin_document
|
||||||
\begin_header
|
\begin_header
|
||||||
\save_transient_properties true
|
\save_transient_properties true
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#LyX file created by tex2lyx 2.4
|
#LyX file created by tex2lyx 2.4
|
||||||
\lyxformat 574
|
\lyxformat 575
|
||||||
\begin_document
|
\begin_document
|
||||||
\begin_header
|
\begin_header
|
||||||
\save_transient_properties true
|
\save_transient_properties true
|
||||||
|
Loading…
Reference in New Issue
Block a user