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
Send Topic Print
Export Syntax in Rules (Read 5113 times)
Johnnie Wilcox - mistersquid
Full Member
*
Offline



Posts: 84
San Francisco, CA
Export Syntax in Rules
Mar 7th, 2009, 10:22am
 
Prior to 4.6.0 I used a rule for untitled notes like this

$Name=^paragraphs(1)^

Which would fill the $Name field with the unmarked-up first paragraph of the note. In 4.6.0, this rule now also returns the markup specified in the export template associated with the note.

Presuming this is expected behavior, how might I get around this? Is there a way to send the text pre-export to the Rule?

======
It turns out the fix for this is relatively simple, but I'm not sure my solution is supported. I converted the Rule to

$Name=^text(plain,^paragraphs(1)^)^

which works but is not explicitly mentioned on p. 267 of the "Tinderbox User's Manual" shipping with 4.6.0. Additionally, the style designation "plain" also works if it comes after the object, ^paragraphs(1)^.
Back to top
 
« Last Edit: Mar 07th, 2009, 10:40am by Johnnie Wilcox - mistersquid »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Export Syntax in Rules
Reply #1 - Mar 7th, 2009, 12:30pm
 
I think the behaviour seen is as (now) expected - the old include probably should have had its HTML mark-up but didn't.  You probably need an as yet missing (I tried) action operator, paragraphs(N). Most export codes are now mirrored by action operators - sadly not this one.

As ^text's syntax is ^text( item[, N] [, plain])^, I'd assume you should be using ^text(item, plain)^ where 'item' is the evaluated expression ^paragraphs(1)^.

I also tried to see if ^paragraphs^ had an optional templates argument, e.g. ^paragraphs(N,templateName)^, but it doesn't.

So, I'd recommend this for now:

$Name = ^text(^paragraphs(1)^,plain)^

...except I notice that I now get the first 2 paragraphs - or one and a blank line if paras are double-line-spaced.

I tried $MyString = ^paragraphs(1)^;$Name= MyString([\^<p>].*[\^</p>]) but though the pattern match using MyString() works it returns true rather than the '.*' match section of the $MyString value.
Back to top
 
 

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



Posts: 5
Sacramento, California
Re: Export Syntax in Rules
Reply #2 - Mar 7th, 2009, 6:25pm
 
I had a similar issue with containers whose OnAdd action was set to name the note from the first 10 words of its text: $Name=^text(this,12). Since many notes are text I've clipped from Web pages, under Tinderbox 4.6 the coding began to show up in the note name.

This change seems to work the way my former OnAdd action did: $Name=^text(this, 10, plain)^

Cheers,

Mark
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Export Syntax in Rules
Reply #3 - Mar 7th, 2009, 6:50pm
 
Also, consider substr() for getting the first N characters of the text.
Back to top
 
 
WWW   IP Logged
Pages: 1
Send Topic Print