From 7d4c560f879a3c9dd7deec4fe7ec0d494714068c Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 16 Jul 2010 15:19:04 +0000 Subject: [PATCH] Remove Nameref support. Too many issues involving translation, quotes, etc. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34920 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/FORMAT | 4 ++++ lib/lyx2lyx/lyx_2_0.py | 35 +++++++++++++++++++++++++++++++++-- lib/ui/stdcontext.inc | 1 - src/Buffer.cpp | 2 +- src/insets/InsetRef.cpp | 8 +++----- 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index 7040ca4b74..60583231d9 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -7,6 +7,10 @@ The good example would be 2010-01-10 entry. ----------------------- +2010-07-16 Richard Heck + * Format incremented to 397 (r34884) + Remove Nameref support + 2010-07-13 Richard Heck * Format incremented to 396 (r34884) nameref support diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index a375de916c..283da64c38 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -2001,6 +2001,35 @@ def revert_nameref(document): add_to_preamble(document, "\usepackage{nameref}") +def remove_Nameref(document): + " Convert Nameref commands to nameref commands " + i = 0 + while 1: + # It seems better to look for this, as most of the reference + # insets won't be ones we care about. + i = find_token(document.body, "LatexCommand Nameref" , i) + if i == -1: + break + cmdloc = i + i += 1 + + # Make sure it is actually in an inset! + # We could just check document.lines[i-1], but that relies + # upon something that might easily change. + # We'll look back a few lines. + stins = cmdloc - 10 + if stins < 0: + stins = 0 + stins = find_token(document.body, "\\begin_inset CommandInset ref", stins) + if stins == -1 or stins > cmdloc: + continue + endins = find_end_of_inset(document.body, stins) + if endins == -1: + document.warning("Can't find end of inset at line " + stins + "!!") + continue + if endins < cmdloc: + continue + document.body[cmdloc] = "LatexCommand nameref" ## @@ -2058,10 +2087,12 @@ convert = [[346, []], [393, [convert_optarg]], [394, []], [395, []], - [396, []] + [396, []], + [397, [remove_Nameref]] ] -revert = [[395, [revert_nameref]], +revert = [[396, []], + [395, [revert_nameref]], [394, [revert_DIN_C_pagesizes]], [393, [revert_makebox]], [392, [revert_argument]], diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc index 1e0bbb1131..159dcea20b 100644 --- a/lib/ui/stdcontext.inc +++ b/lib/ui/stdcontext.inc @@ -92,7 +92,6 @@ Menuset Item " on Page |f" "inset-modify changetype vref" Item "Formatted Reference|t" "inset-modify changetype prettyref" Item "Textual Reference|x" "inset-modify changetype nameref" - Item "Textual Reference plus |l" "inset-modify changetype Nameref" Separator Item "Settings...|S" "inset-settings" End diff --git a/src/Buffer.cpp b/src/Buffer.cpp index d71381e009..b399f64831 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -126,7 +126,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 396; // rgh: nameref +int const LYX_FORMAT = 397; // rgh: remove Nameref support typedef map DepClean; typedef map > RefCache; diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 85100e8099..0d09af17f0 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -53,8 +53,7 @@ bool InsetRef::isCompatibleCommand(string const & s) { || s == "vpageref" || s == "prettyref" || s == "eqref" - || s == "nameref" - || s == "Nameref"; + || s == "nameref"; } @@ -137,7 +136,7 @@ docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const &) const else if (cmd == "prettyref" // we don't really have the ability to handle these // properly in XHTML output - || cmd == "nameref" || cmd == "Nameref") + || cmd == "nameref") display_string = il->prettyCounter(); } else display_string = ref; @@ -217,7 +216,7 @@ void InsetRef::validate(LaTeXFeatures & features) const features.require("prettyref"); else if (cmd == "eqref") features.require("amsmath"); - else if (cmd == "nameref" || cmd == "Nameref") + else if (cmd == "nameref") features.require("nameref"); } @@ -230,7 +229,6 @@ InsetRef::type_info InsetRef::types[] = { { "vref", N_("Standard+Textual Page"), N_("Ref+Text: ")}, { "prettyref", N_("PrettyRef"), N_("FrmtRef: ")}, { "nameref", N_("Reference to Name"), N_("NameRef:")}, - { "Nameref", N_("Name+Textual Page"), N_("NamePgRef:")}, { "", "", "" } };