I am in the process of creating a palette for a specialised "Save as HTML". For context please see this.
How can I grab the CellTags from a Cell[...] object? This is my first iteration, aka testing code:
PaletteNotebook[
Module[{action, create},
create := NotebookCreate[];
action[nb_] := Module[{found, out, cell},
out = create;
SelectionMove[nb, Before, Notebook];
found = NotebookFind[nb, "Input", Next, CellStyle];
If[found != $Failed,
cell = NotebookRead[nb];
NotebookWrite[out, OptionValue[cell, CellTags]] (* 1 *),
NotebookWrite[out, "Not found"]
];
];
Button[Style["Blog it", 12, FontFamily -> "Times"],
action[InputNotebook[]],
Appearance -> "Palette"]
]
]
At the moment it just dumps data into a temporary empty notebook if it finds the Input cell, but the code at (* 1 *) does not print the CellTags the cell has in the InputNotebook[]
. I am thinking that OptionsPattern[]
may be the answer, but I am not sure how to use it. I tried
...
cell = NotebookRead[nb];
tags = cell /. Cell[__, OptionsPattern[]] :> OptionValue[CellTags];
NotebookWrite[out, tags],
...
but it doesn't work either.