Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1 2 
Send Topic Print
Export an agents and an container's children (Read 18769 times)
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Export an agents and an container's children
Reply #15 - Oct 25th, 2010, 10:29am
 
You'll want to use "HTML export" for your task, because "HTML Export" gives you control over which notes you ^include. Tinderbox "Text Export" always exports notes in outline order.

You don't need to have HTML markup in your exported files if you don't want it. Just turn off options like $HTMLMarkupHTML (to turn off markup discovery in styled text) and $HTMLEntities (to omit converting non-ASCII characters to HTML entities).
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Export an agents and an container's children
Reply #16 - Oct 25th, 2010, 10:49am
 
OK. Leave 'a container' as it is. Add a new export template called 'text' and give is this code:
Code:
^text^ 

Open the HTML view for "a container" and set it to use the new template. Also, on the HTML view, change the export extension form ".html" to ".txt".

Change the 'tasks' template code to:
Code:
^indent("\t",$OutlineDepth-1)^^title^
^if(Text)^^indent("\t",$OutlineDepth)^^text^^endIf^
^if(ChildCount)^^children("/Templates/tasks")^
 

At this point, in HTML export you'll see some <p> and </p> - don't worry we'll remove those on export (I come to that later).

Although we want 'plain' text export, we can't use Nakakoji view as it doesn't allow use of ^include()^, and the latter is absolutely necessary to achieve your layout.  So we must use HTML Export, and wherever HTML Export processes ^title^ or ^text^ it adds enclosing <p> and </p> HTML paragraph tags. We could laboriously change, per note, all the attributes like $HTMLParagraphStart, but it's a lot of effort as it must be done for each note being exported. Instead we'll add a Unix command line to the $HTMLExportCommand of "a container".  So, open Info view for "a container", and edit the value for $HTMLExportCommand, adding this code:
Code:
sed 's/<[^>]*p>//g' 

When you open the TXT file that's exported, the <p> tags you see in HTML view will be gone. The command processes the 'finished' HTML view export before the data is written to file.

If all this seems complex for simple text export, it's complexity that arises (unintentionally) from your particular layout.

[Post-edit: simplified sed code]
Back to top
 
« Last Edit: Oct 26th, 2010, 8:39am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Export an agents and an container's children
Reply #17 - Oct 25th, 2010, 11:41am
 
To avoid unwanted paragraph markup, just set $HTMLParagraphStart/End and  $HTMLFirstParagraphStart/End to "".  

You can do this easily in the note's HTML View window, Paragraphs pane. (You'll likely want to make the change in the prototype)

Turning off $HTMLMarkup also disables paragraph markup.
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Export an agents and an container's children
Reply #18 - Oct 25th, 2010, 12:27pm
 
Although prototypes weren't in your demo file (and I didn't want to make assupmtions about what you'd left out), Mark B's point is a good one as it's cleaner and allows you to ditch the $HTMLExportCommand. To implement his idea, make sure all notes used in the to-do list - i.e. notes that are exported, use a prototype that has $HTMLParagraphStart and $HTMLParagraphEnd set to nothing (i.e. delete the existing HTML code). If necessary you can have more than one prototype as long as all exported notes don't export.

Or, if you do need multiple prototype for different parts of the to-do, make a prototype who's only task is to have empty $HTMLParagraphStart and $HTMLParagraphEnd and make the other prototypes all inherit from that; even less editing of attributes! Set the values in one prototype, other prototypes inherit from it, and then the actual notes inherit from the later prototypes. So you might 'correct' the HTML tag issue for, say, 50 notes, by only editing one. A good example of where prototypes can save a lot of work. Plus, if you suddenly found you needed to export those same notes to HTML, again just edit the single 'upstream' prototype to correct all the others inheriting from it.

Disabling $HTMLMarkupText  - or via 'Markup text' in HTML view - would remove the HTML tags but don't apply it to "a container"** as the attribute also controls processing of any ^export^ code, so the includes wouldn't get processed. No problem to disable $HTMLMarkup in the notes getting called via the includes - prototypes, as discussed above, would be the neat way to achieve that.

** The export container used in Sebastian's demo file posted up thread.  This should enable other to play laong by using the same source TBX.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sebastian Stephenson
Full Member
*
Offline



Posts: 100

Re: Export an agents and an container's children
Reply #19 - Oct 26th, 2010, 7:58am
 
An export!! Thank you both marks'

To get rid of the <p>'s I changed the default value of the attribute($HTMLFirstParagarphStart and $HTMLFirstParagraphEnd) for the document in the attributes panel

Three questions left:

what does the "\t" in the code do?

what does the text export note I made earlier on do?

I assumed laos is tasks. Is it?

This is great thank you both!

I tweak this to get it right in the production tinderbox file thanks!!
Back to top
 
« Last Edit: Oct 26th, 2010, 8:10am by Sebastian Stephenson »  
Sebastian Stephenson sebey9   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Export an agents and an container's children
Reply #20 - Oct 26th, 2010, 8:42am
 
^indent("\t",$OutlineDepth)^ implies, emit as many tab (\t) characters as this note's $OutlineDepth. For a root level note that would result in 1 tab.

If you've altered $HTMLFirstParagarphStart & End, then you will also want to delete the $HTMLExportCommand for 'a container' otherwise that code still runs even though it's not now needed.

The 'laos' was a typo - see the original message, which I've corrected.

Quote:
what does the text export note I made earlier on do?
What note? Can you be more specific. All my recent comments refer to your TBX "specimen_flie_for_text_export_problem_3.TBX" ( the flie/file typo is as in the filename).

Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sebastian Stephenson
Full Member
*
Offline



Posts: 100

Re: Export an agents and an container's children
Reply #21 - Oct 26th, 2010, 8:45am
 
Quote:
OK. Leave 'a container' as it is. Add a new export template called 'text' and give is this code:
Code:
Code:
^text^
 



Open the HTML view for "a container" and set it to use the new template. Also, on the HTML view, change the export extension form ".html" to ".txt".


this is the section I am talking about it where the "laos" error was.
Back to top
 
 
Sebastian Stephenson sebey9   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Export an agents and an container's children
Reply #22 - Oct 26th, 2010, 9:44am
 
OK, we need this as there is no built-in template to export just ^text^ which is what you need for "a container". We need ^text^ and not ^text(plain)^ as the latter won't evaluate your ^include^ calls.

Remember you're need to output together two unconnected container's content as text means we can't use Text Export (Nakakoji) and by using HTML Export we have to remove the HTML tags that are otherwise what we'd want.  It's the nature of a workaround!
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sebastian Stephenson
Full Member
*
Offline



Posts: 100

Re: Export an agents and an container's children
Reply #23 - Oct 26th, 2010, 10:35am
 
This is great mark thank you but one question:

here is what the export looks like
Code:
Today my tasks are
=============
data

	data 1
	-some text from data 1
	data 2
	-some text for the export test(from data 2)

	data 3

		sub data 1
		--some text form sub data 1
		sub data 2
		--text form sub data 2


Checklist
======
a second container

	note from second container
	-some text from second container
	note from second container copy
	-some text from second container copy
	note from second container copy 1
	-some text from second container copy 1
 



I modified your code a bit to get more of what I was looking for but do you see that under the headlines it says "a container" and "a second container". Is there any possibility to get rid of them easily enough if not don't worry I try and figure it out

thanks mark
Back to top
 
 
Sebastian Stephenson sebey9   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Export an agents and an container's children
Reply #24 - Oct 26th, 2010, 3:24pm
 
OK, make a new template "wrapper":
Code:
^children("/Templates/tasks")^ 


Alter the content of "a container" to use the new template:
Code:
Today my tasks are
=============
^include("/data","/Templates/wrapper")^
Checklist
======
^include("/a second container","/Templates/wrapper")^
 


Replace template 'tasks' with this code to improve white space layout:
Code:
^indent("\t",$OutlineDepth-1)^^title^
^if(Text)^^indent("\t",$OutlineDepth)^^text^
^endIf^^if(ChildCount)^^children("/Templates/tasks")^^endIf^ 

Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sebastian Stephenson
Full Member
*
Offline



Posts: 100

Re: Export an agents and an container's children
Reply #25 - Oct 27th, 2010, 7:29am
 
mark thank you so much this is great

just to note for reference here is the final tasks template that I am using

Code:
^indent()^^title^
^if(Text)^^indent()^^indent(-)^^text^
^endIf^^if(ChildCount)^^children("/Templates/tasks")^^endif^
 



It a bit simpler but I found that indent() uses $OutlineOrder so it did not need to be declared. Same goes for the '\t'. It produces the same results.

That is not to say you have not been an enormous help. Thank you, I would gotten no where near as far as I did on my own. Thank you.
Back to top
 
 
Sebastian Stephenson sebey9   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Export an agents and an container's children
Reply #26 - Oct 27th, 2010, 9:38am
 
Ah, yes.  In one of my earlier answers, I was using a number of indents based on a modified $OutlineOrder. To use both parameters of ^indent^ you need to specify both, thus the "\t" reference.  You are quite correct that if you just need $OutlineOrder-worth of tabs, you can use the command with no parameters as in your example above.

More importantly, I'm glad we've finally got your desired text export correct!
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1 2 
Send Topic Print