HTML output support, please

Can we have support for outputting field values and other text as HTML?

At the moment, to properly output text fields to HTML (handling the four HTML reserved characters < > " and &) requires every such placeholder e.g. %artist% to be replaced with $replace(%artist%,&,&,<,<,>,>,",")

This makes HTML scripts much more bulky and difficult to read and edit. The standard amd Export Configuration Archive HTML scripts don't do this, so they can go wrong on < > " and & in fields.

I suggest adding

a) an HTML version of every text placeholder e.g.

%placeholderH% . as %placeholder%, but converted to HTML (reserved characters representated as entities)

e.g.

%artist% => Francisco <> Lomuto
%artistH% => Francisco <<Pancho>> Lomuto

b) a function

$html(string) . string converted to HTML (reserved characters representated as entities)

e.g.

$html(The artist is Francisco <> Lomuto) => The artist is Francisco <<Pancho>> Lomuto

If only b) was implemented, the function might be better as $h(string), for compactness.

Thanks.

I suggest to name such an encoding function $htmlenc() because this is a well known name in the world for this task.

I've just came across with this page ...
http://freemarker.org/docs/api/freemarker/...va.lang.String)
See the remarks regarding XML and XHTML.
We have to include some more special characters, e. g. the single quote.

DD.20090811.1254.CEST

suggest to name such an encoding function $htmlenc()
because this is a well known name in the world for this task.

Good suggestion thanks. But then even more a short version e.g. $h() is needed if there were not H-version placeholders.

I've just came across with this page ...
http:
//freemarker.org/docs/api/freemarker/...va.lang.String)

See the remarks regarding XML and XHTML.

You mean

?

We have to include some more special characters, e. g. the single quote.

I see nothing to suggest that. Single quote is not a reserved character in HTML. (Or XML.)

Hi,

htmlspecialchars() is nice and readable.

Traditionally single quotes could be used for quoting attribute values (as still used in this forums code!) and so escaping of them was needed, but I see no need today.

Daz

htmlspecialchars() is nice and readable.

But extremely inaccurate!

Traditionally single quotes could be used for quoting attribute
values (as still used in this forums code!) and so escaping of
them was needed

Only inside attributes i.e. inside tags. My suggestion is only for out-of-tags text.