4

Bug introduced in 11 or earlier and persisting through 12.1

[...] I have filed a report to the development team, raising the issue to them. [...]

[CASE:3802659]


CellPrint[Cell["test", "Text"]]
CellPrint[Cell["test2", "Text", "MyStyle"]]
CellPrint[Cell["test3", "Text", "Text"]]
NotebookImport[EvaluationNotebook[], "Text"]
{"test"}

Since multiple style cells are officially supported I would consider it a bug. Or have I missed something?

Kuba
  • 136,707
  • 13
  • 279
  • 740

1 Answers1

4

I suppose you want that to return all three cells? This does work for that:

NotebookImport[EvaluationNotebook[], "Text" | {"Text", _}]
{"test", "test2", "test3"}

One can also pull only specific combinations:

NotebookImport[EvaluationNotebook[], {"Text", "Text"}]
{"test3"}

Notably this matches none of the examples:

NotebookImport[EvaluationNotebook[], {"Text"}]
{}
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • 1
    It won't catch CellPrint[Cell["test3", {"Whatever", "Text"}]] but it is a good direction and at the end x__ /; ! FreeQ[{x}, "Text"] works, the problem is we need it for each mentioned style as it can happen in general. – Kuba Dec 20 '16 at 18:56