Group Abstract Group Abstract

Message Boards Message Boards

0
|
263 Views
|
3 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How to automatically select the content of all sections outside the code?

Posted 1 month ago

In an nb file, there are many input code lines and corresponding results generated by the code, as well as manually inserted images, etc. What methods do we have to automatically select all content in the file except for the code lines, so that it can be saved for other documents? If manually selecting the corresponding sections is time-consuming for large files, are there any automatic selection methods?

POSTED BY: Wen Dao
3 Replies

Evaluate the line below in you notebook and will create a new notebook with all cells except Input and Code cells. You could put it at the end of your notebook and evaluate just this cell. I am sure there is a better method, so this is just a quick hack.

NotebookPut[Notebook[(Map[NotebookRead])[
       With[{cd = 
      Complement[
       Union[Flatten[
         NotebookCellData[SelectedNotebook[], "CellStyle"]]], {"Code",
         "Input"}]},        
    Select[Cells[], 
     MemberQ[cd, CurrentValue[#1, "CellStyle"][[1]]] & ]]]]]
POSTED BY: Rolf Mertig
Posted 24 days ago

The result achieved by this code is absolutely stunning—this is exactly what we wanted. Thank you so much for your help.

POSTED BY: Wen Dao
Posted 24 days ago

After running the code, only all the sections resulting from the code execution are extracted. How can I modify it to select all other content except the code itself—such as manually entered text, inserted images, and other complete content?

POSTED BY: Wen Dao
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard