# HTML output support, please

**URL:** https://community.mp3tag.de/t/html-output-support-please/8756
**Category:** General Discussion
**Created:** [August 10, 2009, 11:01pm UTC](https://community.mp3tag.de/t/html-output-support-please/8756 "2009-08-10T23:01:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [August 10, 2009, 11:01pm UTC](https://community.mp3tag.de/t/html-output-support-please/8756/1 "2009-08-10T23:01:37Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [August 11, 2009, 8:54am UTC](https://community.mp3tag.de/t/html-output-support-please/8756/2 "2009-08-11T08:54:43Z")

</div>

> [@chrisjj](#):
>
> ... If only 🕶 was implemented, the function might be better as $h(string), for compactness. ...

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)](http://freemarker.org/docs/api/freemarker/template/utility/StringUtil.html#HTMLEnc(java.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

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [August 11, 2009, 10:29am UTC](https://community.mp3tag.de/t/html-output-support-please/8756/3 "2009-08-11T10:29:27Z")

</div>

> 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)](http://freemarker.org/docs/api/freemarker/template/utility/StringUtil.html#HTMLEnc(java.lang.String))  
> See the remarks regarding XML and XHTML.

You mean

> [@](#):
>
> XHTML Encoding. Replaces all '\>' '\<' '&', "'" and '"' with entity reference suitable for XHTML decoding in common user agents (including legacy user agents, which do not decode "'" to "'", so "'" is used instead [see [http://www.w3.org/TR/xhtml1](http://www.w3.org/TR/xhtml1) #C\_16])

?

> 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.)

---

<div class="post-metadata">

### Author: ![DazBYorks](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dazbyorks/32/4904_2.png) [@DazBYorks](https://community.mp3tag.de/u/DazBYorks)
#### Post date: [August 11, 2009, 10:47am UTC](https://community.mp3tag.de/t/html-output-support-please/8756/4 "2009-08-11T10:47:28Z")

</div>

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

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [August 11, 2009, 11:15am UTC](https://community.mp3tag.de/t/html-output-support-please/8756/5 "2009-08-11T11:15:58Z")

</div>

> 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.
