From 98a5072a5863d6db64967324f01a6038275c4f85 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sat, 20 Jun 2015 01:44:22 +0200 Subject: [PATCH] Fix a couple of issues with macros and previews * Fix typo causing to only account for the first char of a macro name * Also check for macros as arguments of other macros --- lib/scripts/lyxpreview2bitmap.py | 2 +- src/mathed/InsetMathHull.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/scripts/lyxpreview2bitmap.py b/lib/scripts/lyxpreview2bitmap.py index a7d76236fb..c2b94d4ed5 100755 --- a/lib/scripts/lyxpreview2bitmap.py +++ b/lib/scripts/lyxpreview2bitmap.py @@ -160,7 +160,7 @@ def extract_metrics_info(dvipng_stdout): def fix_latex_file(latex_file, pdf_output): documentclass_re = re.compile("(\\\\documentclass\[)(1[012]pt,?)(.+)") - def_re = re.compile(r"(\\newcommandx|\\global\\long\\def)(\\[a-zA-Z])(.+)") + def_re = re.compile(r"(\\newcommandx|\\global\\long\\def)(\\[a-zA-Z]+)(.+)") usepackage_re = re.compile("\\\\usepackage") userpreamble_re = re.compile("User specified LaTeX commands") enduserpreamble_re = re.compile("\\\\makeatother") diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 4e18b72420..0cfaad0dc0 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -647,6 +647,10 @@ void InsetMathHull::usedMacros(MathData const & md, DocIterator const & pos, if (macros.find(name) == end) continue; macros.erase(name); + // Look for macros in the arguments of this macro. + for (idx_type idx = 0; idx < mi->nargs(); ++idx) + usedMacros(mi->cell(idx), pos, macros, defs); + // Look for macros in the definition of this macro. MathData ar(pos.buffer()); MacroData const * data = pos.buffer()->getMacro(name, pos, true); -- 2.39.2