Print HTML in Tinderbox $Text

I am writing a note and don’t want to have HTML rendered in it, but rather have it render just the text. How do I do this?

What I have and want:

How it is coming out in preview.

Question is, how do I comment the <…> so it renders as text and not as HTML?

The last line of your lest should be:

Name: ^value($EmailAddress)^

which when processed as part of ^text^ will encode as:

<p>Name: j.doe@example.com</p>

which then should look correct in preview mode.

TL;DR—the Preview window is essentially showing an exported HTML page but without needing to do the export. so think ^export^ code (which of course can access attributes via ^value()^ and embedded action code.

Sorry, I don’t think you understand.

I’m not trying to import a value. I’m literally trying to write "Name " but Tinderbox see the “<>” as HTML and tries to render it. I don’t want this.

So, $EmailAddress isn’t a valid email address but and address and screen label , i.e not :

j.doe@example.com

But

John X. Doe<j.doe@example.com>

That’s do-able. Next, what is the preview for? IOW, are you actually trying to make a working mailto: link of the above? In which case we want ouptut:

<a href="mailto:j.doe@example.com">John X. Doe</a>

to give Name: j.doe@example.com with the latter being a clickable link opening your email client with an email to ‘j.doe@example.com’. Or (working from memory):

<a href="mailto:%22John%20X%20Doe%22%3j.doe@example.com%3e">John X. Doe</a>

to get Name: John X. Doe with the latter being a clickable link opening your email client with an email addressed on-screen to ‘John X. Doe’ via email address ‘j.doe@example.com’

Sorry for the questions. I’m just trying to avoid a few rounds of “one more thing” to get the the right end point.

HTML reserves the character < to mean “the start of a tag.” So, is interpreted as a tag.

The sequence < is an HTML entity that corresponds to the glyph < but does not begin an HTML tag.

An alternative, if I recall aright, is that < characters inside

(preformatted) tags aren’t treated as tags, but you probably don’t want to bother with that.

I don’t want this to be a functioning link. I want it to simply show the text "Name ". How do I comment the <…> so that prevview shows this as text and does not read it as HTML.

Here is another example.

In the image below, I have a bunch of code that I want to display as text.

Preview renders it and does not display it as text:

How can I bloke out the code so it renders as text?

put <code></code> tags in the $Text around the code samples, ^text^ export will retain these and cause the (preview) browser to render that text in monospace font. If you have discrete lines of code (i.e. with line breaks between lines) use <pre>/</pre> instead. See more on exporting code samples.

OK, sadly we don’t have a definite example string, so I’ll assume you have an $EmailAddress value with a string like "<j.doe@example.com>". We want it to export as "&lt;j.doe@example.com&gt;" to the angle brackets show as literal characters on screen. Here is our $Text:

On the shores of Gitche Gumee,
Of the shining Big-Sea-Water,
Name: ^value(escapeHTML($EmailAddress))^

which exports as:

<p>On the shores of Gitche Gumee,</p>
<p>Of the shining Big-Sea-Water,</p>
<p>Name: &lt;j.doe@example.com&gt;</p>

which renders as :

On the shores of Gitche Gumee,

Of the shining Big-Sea-Water,

Name: <j.doe@example.com>

See more on escapeHTML(). Remember, inside ^value()^, it is literal text, values from attributes or action code. So, we need to add HTML encoding of HTML mark-up-like characters—e.g. angle brackets—in the $EmailAddress whilst still in action code context before exporting the result to the HTML output (now in HTML-safe form) via the ^value()^ call.

Sorry, I don’t mean to be difficult. This is just not working for me. To be clear, I’m not trying to do this in an export template, I’m trying to do this in $Text. I want the code to be displayed as text.

I tried this, no joy.

^value(escapeHTML($AttendedNames=runCommand((“awk -F ’ <’ ‘/</ {print $1}’|awk 'FNR==1 " + “{printf(” + '”%s",’ + “$0);next}” + “{printf(” + ‘";%s",’ + “$0)}’”),$Text);))^

The argument to escapeHTML must be a string. But you can’t put this particular string into either single or double quotes, because it contains both single and double quotes.

Instead, put it in a string attribute, and use ^value(escapeHTML($ThatAttribute))

Is there no easier way? I really don’t want this to be an attribute, I simply want it to be inline text.

This does seem to work, which is good.

However, if I have numerous examples of code in one not the I need to create a bunch of code attributes. This does not feel efficient. Totally admit I may be missing some big aha insight.

Think about it from the point of view of the program.

You: “Say cheese!”
Tinderbox: cheese!
You: Say “Mary read ‘War and Peace’ yesterday.”
Tinderbox: Mary read ‘War and Peace’ yesterday.
You: Say “Another good book is ‘“Hello”, He Lied’ by Lynda Obst.”
Tinderbox: “Another good book is '”
You: What gives?
Tinderbox: I said what you told me.
You: That’s not what I meant.
Tinderbox: I started at the quotation mark, and continued to the matching quotation mark.

As illustrated above, however many escape mechanisms you have, examples will still need to escape the escapes. And here, we’re talking about special parsing by Tinderbox and also by HTML.

3 Likes

Ya, that makes sense. I appreciate your taking the time to help me see the world through the eyes of the program.

Did you try <code> and or <pre>, as in:

<code>^value($Code)^</code>

or

<pre>^value($Code)^</pre>

?

Ya, both.

Odd - do you have a demo file. It defies logic those shouldn’t work, but without seeing real code it’s hard to tell.

Try using the entity codes. &lt; and &gt; – it works for me.

Your longer awk example can be handled the same way – use TextSoap or an online tool that will entity-encode text for you. Search for “HTML entity encode online” and several options will pop up.

Funny you ask, yes I do, please see attached TBXUC - ParseTextToSemiColonList.tbx (652.1 KB) .

I’m working on creating a format for memorializing my Tinderbox use cases and solutions. In addition to helping me with the code insertion (see Parse Names, Parse Emails, Considerations) issue, can you also take a look at three others?

First, I did try the suggestion in the Parse Names note, but it ends up turning all my preview formatting through the document to code format. It does not work at all for the Stamp examples; the only thing that works for this is the attribute insertion idea Mark provided.

Secondly, any idea on the best way to handle embedded images in a demo file like this? I’d love to have the images exportable, but I can’t do this if the file is shared with others as the images will be on my hard drive.

Thirdly, any ideas on how to improve this use case explanation format? I’d like to create more of these. I think they’ll be useful for others, they give attribution to those that help, and I learn a lot!

1 Like

Try the entity encoding I pointed out to you. It’s a standard way of handling HTML code within HTML.

1 Like