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
Is ^encode()^ working correctly? (Read 10173 times)
Charles Turner
Full Member
*
Offline



Posts: 180
New York, USA
Is ^encode()^ working correctly?
Jun 26th, 2009, 8:49pm
 
I was reviewing the OPML export script on the WIKI, and stumbled upon an odd behavior. It produces > for example, instead of >.

I stripped the problem down, and if you create an HTML template that just has only ^encode(foo>bar)^, you'll get foo>bar as the export text.

Charles
Back to top
 
 
WWW   IP Logged
Johnnie Wilcox - mistersquid
Full Member
*
Offline



Posts: 84
San Francisco, CA
Re: Is ^encode()^ working correctly?
Reply #1 - Jun 27th, 2009, 7:43am
 
If "encode()" is doing what you say, it is working properly.

Page 281 of the User's manual documents that

Code:
^encode ( what ) translates special characters such as "<" and ">" into HTML
entities before exporting them 

Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Is ^encode()^ working correctly?
Reply #2 - Jun 27th, 2009, 8:33am
 
If double-encoding is not what you want, you can single-encode in several ways.  Two that come to mind are

a) Set HTMLQuoteHTML to true, OR
b) ^value(escapeHTML("the string"))
Back to top
 
 
WWW   IP Logged
Charles Turner
Full Member
*
Offline



Posts: 180
New York, USA
Re: Is ^encode()^ working correctly?
Reply #3 - Jun 27th, 2009, 10:53am
 
OK, I was unaware of double-encoded entities. Seems a little strange to encode the encoding, expecially when the & ampersand character is never dispensed with.

Given my interest in OPML version 1.0, or the current format that Omnioutliner can read, there doesn't seem any built-in to do linefeed conversions to &#10 in Tbox, so I don't see how I can avoid an extra processing step.

Is it possible to use runCommand() in an export template?

Thanks! Charles
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Is ^encode()^ working correctly?
Reply #4 - Jun 27th, 2009, 11:17am
 
Actions can be accessed several ways:
  • ^action(expression)^. See here.
  • HTMLExportCommand - see here.

As with any multi-facetted tool like Tinderbox, there's often no one single way to do things.  State as much is only to invite others to prove why it doesn't work for there needs.

If stuck, the best way is probably to re-state the problem is terms of (a) what you can't do and as importantly (b) what the outcome is/what you're trying to do next.  Indeed, it is (b) that often dictates the best solution to (a).

I get impression that the OPML page in the wiki has outdated code and/or the code needs some qualifying comment.  I'll confess that OPML is something of which I know conceptually but don't use actively - IOW, I don't really know what's wrong with the existing text.  However, if someone can indicate what's wrong, in my wiki gardener's hat I'll happily volunteer to update the wiki page in question. If that helps!
Back to top
 
 

--
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: Is ^encode()^ working correctly?
Reply #5 - Jun 27th, 2009, 11:35am
 
RunCommand when exporting: sure. But see also HTMLExportCommand, which passes the exported page to a command-line filter.
Back to top
 
 
WWW   IP Logged
Charles Turner
Full Member
*
Offline



Posts: 180
New York, USA
Re: Is ^encode()^ working correctly?
Reply #6 - Jun 27th, 2009, 1:52pm
 
Thanks Mark(s) A & B-

Quote:
I get impression that the OPML page in the wiki has outdated code and/or the code needs some qualifying comment.

It mostly works. The overall behavior and translation of by template is fine. OmniOutliner (I can't speak for other v.1 OPML) chokes on the double-encoded entities, and needs linefeeds (\n, 0x0a) to be escaped as &#10. I think the biggest issue is that OmniOutliner chokes with no indication of why, and that there is lots of testament on your Wiki page to the script not running flawlessly.

Likely I'll have something working correctly before the weekend is out, and can post it for review.

Best, Charles
Back to top
 
 
WWW   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Is ^encode()^ working correctly?
Reply #7 - Jun 27th, 2009, 8:17pm
 
There's an OPML export example in recent Tinderbox weekend CDs. It's quite straightforward, but I'm on the way to Hypertext 2009 today and can't easily post it.

The page template was

<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>^title^</title>
<ownerName></ownerName>
</head>
   <body>
         ^children
     </body>
</opml>

and the item template (also the default template)

<outline text="^title^" _note="^get(Text)">
^children
</outline>
Back to top
 
 
WWW   IP Logged
Charles Turner
Full Member
*
Offline



Posts: 180
New York, USA
Re: Is ^encode()^ working correctly?
Reply #8 - Jun 28th, 2009, 2:31pm
 
Hi Mark B.-

Thanks for the post. I spent some time with the template you posted, and learned a lot.

One thing it doesn't do is provide escapes for the character entities that OmniOutliner3 requires. These are:

\n -> &#10;
" -> &quot;
& -> &amp;
< -> &lt;
> -> &gt;


I think that Tbox uses 0x0d for newline, so perhaps folks haven't been bit by this yet. It also seems OO3 is forgiving of "less than," although it may simply stop parsing after it sees one.

I don't think Tbox provides these translations in some neat, single action, so my solution was to write a small Ruby script to handle them.

Your post also creates an outline only from the children of the selected note. What I had liked about the template posted on the Tbox Wiki was it it would, if the first-top-level note was selected, walk down its siblings, and in effect export the entire Tbox document. (It doesn't handle Agents very well, though. But I didn't check the behavior of your posted files with Agents.)

I thought I could export the entire note hierarchy with your post, but when I went to Chart View and selected the root document, the export button was greyed out even though the OPML file was correctly displayed in the HTML View window. (I know I could probably move the entire note hierarchy under a single, top-level note, but I didn't bother.)

The other thing that OO3 users might want to take advantage of are it's columns. It's very easy to include Tbox template code that would export Tbox Note Attributes out as OO3 column data. That way you can preserve all that Tbox metadata that you've spent so much time on.

If anyone has an interest in my work, please let me know. I'm almost done with everything, but I think use will always require some configuration, so it may not be everyone's cup of tea.

The scripts Mark posted work well if you keep in mind the encoding issues I mentioned above.

Best, Charles
Back to top
 
 
WWW   IP Logged
Charles Turner
Full Member
*
Offline



Posts: 180
New York, USA
Re: Is ^encode()^ working correctly?
Reply #9 - Jun 28th, 2009, 5:16pm
 
Hi all-

I was running a test and don't believe my template was doing all this escaping of character entities in an HTML View:

<outline text="Dummy" _note="       &#10; &#10; ! &quot; # $ % &amp; ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; &lt; = &gt; ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ ] _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
&Auml; &Aring; &Ccedil; &Eacute; &Ntilde; &iuml; &Uuml; &aacute; &agrave; &acirc; &auml; &atilde; &aring; &ccedil; &eacute; &egrave; &ecirc; &euml; &iacute; &igrave; &icirc; &iuml; &ntilde; &oacute; &ograve; &ocirc; &ouml; &otilde; &uacute; &ugrave; &ucirc; &uuml; &deg; &cent; &pound; &bull; &szlig; &reg; &copy; &trade; &#x2260; &AElig; &Oslash; &yen; &mu; &delta; &sum; &aelig; &oslash; &iquest; &iexcl; &Delta; &laquo; &raquo; &hellip; &Agrave; &Atilde; &Otilde; &OElig; &oelig; &mdash; &mdash; &yuml; &Yuml; &euro; &bdquo; &Acirc; &Ecirc; &Aacute; &Euml; &Egrave; &Iacute; &Icirc; &Iuml; &Igrave; &Oacute; &Ocirc; &Ograve; &Uacute; &Ucirc; &Ugrave; ">


Is there any way to shut this off and get raw Mac Roman output for the characters above 128?

Thanks, Charles

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

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Is ^encode()^ working correctly?
Reply #10 - Jun 30th, 2009, 1:04am
 
See the attribute HTMLEntities.
Back to top
 
 
WWW   IP Logged
Charles Turner
Full Member
*
Offline



Posts: 180
New York, USA
Re: Is ^encode()^ working correctly?
Reply #11 - Jun 30th, 2009, 11:53am
 
Thanks Mark B.!
Back to top
 
 
WWW   IP Logged
Pages: 1
Send Topic Print