This was puzzling me for a while, and I figured it out and thought it
might be useful to others.
The objective is to use NewDocumentPlugin (http://www.TiddlyTools.com/
#NewDocumentPlugin) to export only the actual text of a tiddler, with
all other elements stripped out. I wanted to be able to edit files in
TW for export without any information showing that they are tiddlers:
no title, no subtitle, no tag information, just the text of the
tiddler's body, as it were. I export these for printing, so I wanted
to preserve the formatting (copy/paste seems to not preserve
formatting).
It's pretty easy, all I did was open the ViewTemplate tiddler and give
the DIV with the class of 'viewer' an ID. I named my 'textOnly', but I
suppose this ID could be whatever one wanted. Then I used the
NewDocumentPlugin to export a specific DOM element and gave 'textOnly'
as the ID. It exports a pretty minimal file, preserving the style of
the original.
This little trick is useful to me and I hope it will be useful to
others (though many others may have thought of it already).
If any more experienced user can see a problem with doing this, please
let me know!
Be well!
ACodispo
as long as this works for you, then cool....
however...
If you display more than one tiddler at a time, the DOM elements that
are created based on the ViewTemplate definition will contain an
instance of the same viewer element ID, one for each tiddler that is
displayed.
However, using the same ID multiple times in a single document is not
advisable. Here's why: Since the DOM structure is a tree,
getElementById() can search using either pre-order (depth-first) or
post-order (breadth-first) traversal.
However, since that kind of specific implementation detail can differ
for any given browser, the results are not necessarily the same for
all browsers. I think that FireFox returns the first element with the
ID. Another browser might give you the "last" element with that ID.
Who knows what IE does!!! (assuming it doesn't simply crash with some
meaningless "object error" :-)
Fortunately, I can suggest another way to approach this problem of
removing unwanted content before taking a snapshot: Instead of
actually removing them from the template, just use some CSS in a
customized StyleSheet tiddler to hide those unwanted elements... then
take your HTML snapshot using NewDocumentPlugin with the "displayArea"
ID (to get the entire set of displayed tiddlers)
You might use this CSS as a starting point for hiding the content. It
is very similar to the "TotallyTiddlers" stylesheet that I've got on
TiddlyTools...
-----------------
/* hide tiddler functions, menus, and breadcrumbs */
.tiddler .toolbar, .tiddler .tagged, .tiddler .tagging, .tiddler .title, .tiddler .subtitle,
#mainMenu, #sidebar { display:none !important; }
/* reclaim space left by sidebar and main menu*/
#displayArea { margin:1em !important; }
-----------------
HTH,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
ACodispo