Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Exporting from Tinderbox >> Is ^encode()^ working correctly?
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1246063762

Message started by Charles Turner on Jun 26th, 2009, 8:49pm

Title: Is ^encode()^ working correctly?
Post by Charles Turner on 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

Title: Re: Is ^encode()^ working correctly?
Post by Johnnie Wilcox - mistersquid on 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

Title: Re: Is ^encode()^ working correctly?
Post by Mark Bernstein on 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"))

Title: Re: Is ^encode()^ working correctly?
Post by Charles Turner on 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

Title: Re: Is ^encode()^ working correctly?
Post by Mark Anderson on 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!

Title: Re: Is ^encode()^ working correctly?
Post by Mark Bernstein on Jun 27th, 2009, 11:35am

RunCommand when exporting: sure. But see also HTMLExportCommand, which passes the exported page to a command-line filter.

Title: Re: Is ^encode()^ working correctly?
Post by Charles Turner on 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

Title: Re: Is ^encode()^ working correctly?
Post by Mark Bernstein on 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>

Title: Re: Is ^encode()^ working correctly?
Post by Charles Turner on 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

Title: Re: Is ^encode()^ working correctly?
Post by Charles Turner on 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


Title: Re: Is ^encode()^ working correctly?
Post by Mark Bernstein on Jun 30th, 2009, 1:04am

See the attribute HTMLEntities.

Title: Re: Is ^encode()^ working correctly?
Post by Charles Turner on Jun 30th, 2009, 11:53am

Thanks Mark B.!

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.