The problem is that InsetNote do not produce any text nor latex output, so it can be matched freely by the regexp. The patch adds an output_notes member of OutputParam, default to false, and setting to true on advanced s&r. I set it to true also for the stringification of the search buffer, so now one can also *search* for notes.
Comments? A/
diff --git a/src/OutputParams.cpp b/src/OutputParams.cpp index cf81253..8ccf78c 100644 --- a/src/OutputParams.cpp +++ b/src/OutputParams.cpp @@ -31,7 +31,7 @@ OutputParams::OutputParams(Encoding const * enc) dryrun(false), silent(false), pass_thru(false), html_disable_captions(false), html_in_par(false), html_make_pars(true), for_toc(false), for_tooltip(false), - for_search(false), includeall(false) + for_search(false), output_notes(false), includeall(false) { // Note: in PreviewLoader::Impl::dumpPreamble // OutputParams runparams(0); diff --git a/src/OutputParams.h b/src/OutputParams.h index 598b575..ca392ac 100644 --- a/src/OutputParams.h +++ b/src/OutputParams.h @@ -270,6 +270,9 @@ public: /// Are we generating this material for use by advanced search? bool for_search; + /// Do we want Notes on output (used only for adv search) + bool output_notes; + /// Include all children notwithstanding the use of \includeonly bool includeall; diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 6bb294d..b6d05fc 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -224,7 +224,7 @@ bool InsetNote::isMacroScope() const void InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const { - if (params_.type == InsetNoteParams::Note) + if (params_.type == InsetNoteParams::Note && !runparams_in.output_notes) return; OutputParams runparams(runparams_in); @@ -258,7 +258,7 @@ void InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const int InsetNote::plaintext(odocstringstream & os, OutputParams const & runparams_in, size_t max_length) const { - if (params_.type == InsetNoteParams::Note) + if (params_.type == InsetNoteParams::Note && !runparams_in.output_notes) return 0; OutputParams runparams(runparams_in); @@ -277,7 +277,7 @@ int InsetNote::plaintext(odocstringstream & os, int InsetNote::docbook(odocstream & os, OutputParams const & runparams_in) const { - if (params_.type == InsetNoteParams::Note) + if (params_.type == InsetNoteParams::Note && !runparams_in.output_notes) return 0; OutputParams runparams(runparams_in); diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index f3b3eef..e6e9922 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -737,6 +737,7 @@ static docstring buffer_to_latex(Buffer & buffer) runparams.linelen = 80; //lyxrc.plaintext_linelen; // No side effect of file copying and image conversion runparams.dryrun = true; + runparams.output_notes = true; pit_type const endpit = buffer.paragraphs().size(); for (pit_type pit = 0; pit != endpit; ++pit) { TeXOnePar(buffer, buffer.text(), pit, os, runparams); @@ -758,6 +759,7 @@ static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions co runparams.linelen = 100000; //lyxrc.plaintext_linelen; runparams.dryrun = true; runparams.for_search = true; + runparams.output_notes = true; for (pos_type pit = pos_type(0); pit < (pos_type)buffer.paragraphs().size(); ++pit) { Paragraph const & par = buffer.paragraphs().at(pit); LYXERR(Debug::FIND, "Adding to search string: '" @@ -1016,6 +1018,7 @@ docstring stringifyFromCursor(DocIterator const & cur, int len) runparams.linelen = 100000; //lyxrc.plaintext_linelen; // No side effect of file copying and image conversion runparams.dryrun = true; + runparams.output_notes = true; LYXERR(Debug::FIND, "Stringifying with cur: " << cur << ", from pos: " << cur.pos() << ", end: " << end); return par.asString(cur.pos(), end, @@ -1061,6 +1064,7 @@ docstring latexifyFromCursor(DocIterator const & cur, int len) runparams.linelen = 8000; //lyxrc.plaintext_linelen; // No side effect of file copying and image conversion runparams.dryrun = true; + runparams.output_notes = true; if (cur.inTexted()) { // @TODO what about searching beyond/across paragraph breaks ? @@ -1408,6 +1412,8 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M runparams.flavor = OutputParams::LATEX; runparams.linelen = 8000; //lyxrc.plaintext_linelen; runparams.dryrun = true; + runparams.output_notes = true; + TeXOnePar(repl_buffer, repl_buffer.text(), 0, os, runparams); //repl_buffer.getSourceCode(ods, 0, repl_buffer.paragraphs().size(), false); docstring repl_latex = ods.str();