j = j + 1
+def convert_macro_global(document):
+ "Remove TeX code command \global when it is in front of a macro"
+ # math macros are nowadays already defined \global, so that an additional
+ # \global would make the document uncompilable, see
+ # http://bugzilla.lyx.org/show_bug.cgi?id=5371
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_inset FormulaMacro", i)
+ if i != -1 and i > 13:
+ if document.body[i-6] == "global":
+ del document.body[i-13 : i]
+ else:
+ return
+ i = i - 12
+
+
def revert_macro_optional_params(document):
"Convert macro definitions with optional parameters into ERTs"
# Stub to convert macro definitions with one or more optional parameters
document.header.insert(i, '\\use_default_options false')
+def revert_backref_options(document):
+ ' Revert option pdf_backref=page to pagebackref '
+ i = find_token(document.header, "\\pdf_backref page", 0)
+ if i != -1:
+ document.header[i] = "\\pdf_pagebackref true"
+
+
+def convert_backref_options(document):
+ ' We have changed the option pagebackref to backref=true '
+ i = find_token(document.header, "\\pdf_pagebackref true", 0)
+ if i != -1:
+ document.header[i] = "\\pdf_backref page"
+ j = find_token(document.header, "\\pdf_pagebackref false", 0)
+ if j != -1:
+ del document.header[j]
+ # backref=true was not a valid option, we meant backref=section
+ k = find_token(document.header, "\\pdf_backref true", 0)
+ if k != -1 and i != -1:
+ del document.header[k]
+ elif k != -1 and j != -1:
+ document.header[k] = "\\pdf_backref section"
+
##
# Conversion hub
#
[295, [convert_htmlurl, convert_url]],
[296, [convert_include]],
[297, [convert_usorbian]],
- [298, []],
+ [298, [convert_macro_global]],
[299, []],
[300, []],
[301, []],
[340, [add_plain_layout]],
[341, []],
[342, []],
- [343, [convert_default_options]]
+ [343, [convert_default_options]],
+ [344, [convert_backref_options]]
]
-revert = [[342, [revert_default_options]],
+revert = [[343, [revert_backref_options]],
+ [342, [revert_default_options]],
[341, [revert_mongolian]],
[340, [revert_tabulators, revert_tabsize]],
[339, []],