Bug of NotebookRead

*To*: mathgroup at smc.vnet.net*Subject*: [mg100125] Bug of NotebookRead*From*: Hannes Kessler <HannesKessler at hushmail.com>*Date*: Mon, 25 May 2009 06:18:55 -0400 (EDT)

Hello, cell tags could be very useful to extract quickly selected information from notebooks, see David Reiss presentation http://scientificarts.com/worklife/conference2008.html But be aware of the following bug of NotebookRead applied to tagged cells in a structured notebook with sections and subsections: The section cell and the input / output cells in the example are tagged, but not the subsection cell. The resulting notebook contains only the section cell. The tagged input/ouput cells are lost as a consequence of the read notebook data containing a wrong CellGroupData [[{Cell[..]},Cell[..]] instead of a correct CellGroupData[[{Cell [..],Cell[..]}]. This could be fixed by a corresponding replacement rule. But the second input/output cell is missing completely and cannot be recovered at all. notebook1 = Notebook[{ Cell["Section 1", "Section", CellTags -> "zzz"], Cell["Subsection 1 (no tag)", "Subsection"], Cell[BoxData[RowBox[{"x", "=", "1"}]], "Input", CellTags -> "zzz"], Cell[BoxData["1"], "Output", CellTags -> "zzz"], Cell[BoxData[RowBox[{"y", "=", "2"}]], "Input", CellTags -> "zzz"], Cell[BoxData["2"], "Output", CellTags -> "zzz"] }]; notebookObject = NotebookPut[notebook1, WindowTitle -> "Notebook 1"]; NotebookFind[notebookObject, "zzz", All, CellTags]; notebookData = NotebookRead[notebookObject] notebook2 = Notebook[Flatten[{notebookData}]]; NotebookPut[notebook2, WindowTitle -> "Notebook 2"]; Did anybody encounter this problem, are there workarounds? I am new to the tagging approach and a bit frustrated as this was my very first experience with it. I am using Mathematica 7.0.1 on Windows XP Best regards, Hannes Kessler