mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Improve the nameref reversion routine. We don't need Nameref anymore,
since that was removed. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36083 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e97c5ba9da
commit
58fa331b8b
@ -24,7 +24,8 @@ import unicodedata
|
|||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
from parser_tools import find_token, find_end_of, find_tokens, \
|
from parser_tools import find_token, find_end_of, find_tokens, \
|
||||||
find_end_of_inset, find_end_of_layout, get_value, get_value_string
|
find_end_of_inset, find_end_of_layout, find_token_backwards, \
|
||||||
|
get_value, get_value_string
|
||||||
|
|
||||||
from lyx2lyx_tools import add_to_preamble, insert_to_preamble, \
|
from lyx2lyx_tools import add_to_preamble, insert_to_preamble, \
|
||||||
put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \
|
put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \
|
||||||
@ -1585,14 +1586,12 @@ def revert_nameref(document):
|
|||||||
cmdloc = i
|
cmdloc = i
|
||||||
i += 1
|
i += 1
|
||||||
# Make sure it is actually in an inset!
|
# Make sure it is actually in an inset!
|
||||||
|
# A normal line could begin with "LatexCommand nameref"!
|
||||||
# We could just check document.lines[i-1], but that relies
|
# We could just check document.lines[i-1], but that relies
|
||||||
# upon something that might easily change.
|
# upon something that might easily change.
|
||||||
# We'll look back a few lines.
|
# So let's see if we're in a ref inset...
|
||||||
stins = cmdloc - 10
|
stins = find_token_backwards(document.body, "\\begin_inset CommandInset ref", cmdloc)
|
||||||
if stins < 0:
|
if stins == -1:
|
||||||
stins = 0
|
|
||||||
stins = find_token(document.body, "\\begin_inset CommandInset ref", stins)
|
|
||||||
if stins == -1 or stins > cmdloc:
|
|
||||||
continue
|
continue
|
||||||
endins = find_end_of_inset(document.body, stins)
|
endins = find_end_of_inset(document.body, stins)
|
||||||
if endins == -1:
|
if endins == -1:
|
||||||
@ -1600,8 +1599,10 @@ def revert_nameref(document):
|
|||||||
continue
|
continue
|
||||||
if endins < cmdloc:
|
if endins < cmdloc:
|
||||||
continue
|
continue
|
||||||
refline = find_token(document.body, "reference", stins)
|
|
||||||
if refline == -1 or refline > endins:
|
# ok, so it is in an InsetRef
|
||||||
|
refline = find_token(document.body, "reference", stins, endins)
|
||||||
|
if refline == -1:
|
||||||
document.warning("Can't find reference for inset at line " + stinst + "!!")
|
document.warning("Can't find reference for inset at line " + stinst + "!!")
|
||||||
continue
|
continue
|
||||||
m = rx.match(document.body[refline])
|
m = rx.match(document.body[refline])
|
||||||
@ -1610,10 +1611,9 @@ def revert_nameref(document):
|
|||||||
continue
|
continue
|
||||||
foundone = True
|
foundone = True
|
||||||
ref = m.group(1)
|
ref = m.group(1)
|
||||||
newcontent = ['\\begin_inset ERT', 'status collapsed', '', \
|
newcontent = put_cmd_in_ert('\\' + cmd + '{' + ref + '}')
|
||||||
'\\begin_layout Plain Layout', '', '\\backslash', \
|
|
||||||
cmd + '{' + ref + '}', '\\end_layout', '', '\\end_inset']
|
|
||||||
document.body[stins:endins + 1] = newcontent
|
document.body[stins:endins + 1] = newcontent
|
||||||
|
|
||||||
if foundone:
|
if foundone:
|
||||||
add_to_preamble(document, "\usepackage{nameref}")
|
add_to_preamble(document, "\usepackage{nameref}")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user