4
$\begingroup$

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?

$\endgroup$
4
$\begingroup$

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"}]
{}
$\endgroup$
1
  • 1
    $\begingroup$ 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. $\endgroup$
    – Kuba
    Dec 20 '16 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.