PUBLIE : Text filters

**SPIP**

# Article validé

L’article "**Text filters** (https://www.spip.net/en_article6559.html)"
vient d’être publié par b_b.

* * *

## Text filters

mardi 19 mai 2020 , par [jack](.././?page=auteur&id_auteur=593&)

This table summarizes the filters that modify the rendering of tags that
produce text in HTML format, what they do, and when to use them.

Text filters

Filtre
Effect & utility
Input text / output text

**textebrut** (https://www.spip.net/ecrire/?exec=article&id_article=4317)
Replaces ``, `<br>` and double line breaks with single line breaks ;
non-breaking spaces and double spaces with single spaces.
Uses to insert text into **`<meta>` tags, and other HTML tags.**
`William Shakespeare :né à Stratford-sur-Avon`

    William Shakespeare :
    né à Stratford-sur-Avon

**texte_backend**
(https://www.spip.net/ecrire/?exec=article&id_article=4287)
Formats text for **XML feeds**.
Particularly useful in RSS feed skeletons.
`<strong>William Shakespeare</strong> naquit à Stratford-sur-Avon`

`&lt;p&gt;&lt;strong&gt;William Shakespeare&lt;/strong&gt; naquit à
Stratford-sur-Avon &lt;/p&gt;`

**attribut_html**
(https://www.spip.net/ecrire/?exec=article&id_article=4282)
Formats text for **HTML Attributes**.
Typically used, in the attributes `<title>`, `<alt>`...
`2 est "supérieur" à 1`

`2 est &quot;supérieur&quot; à 1`

**texte_script**
(https://www.spip.net/ecrire/?exec=article&id_article=4281)
Formats text for **PHP and JS scripts**.
Escape the quotes
`SPIP, Système de publication pour l'internet`

`SPIP, Système de publication pour l\'internet`

**safehtml** (https://www.spip.net/ecrire/?exec=article&id_article=4310)
Escapes the **PHP and JS code**
To be used to secure texts coming from outside (forums, syndications...)
`<script type="text/javascript">...</script>`

`<code class="echappe-js"><script type="text/javascript">...</script></
code>`

**supprimer_tags**
(https://www.spip.net/ecrire/?exec=article&id_article=4315)
Removes all HTML tags while keeping the content of these same tags.
Enables you to obtain a "raw" text.
`<strong>William Shakespeare</strong> naquit à
<em>Stratford-sur-Avon</em>`

`William Shakespeare naquit à Stratford-sur-Avon`

**charset2unicode**
(https://www.spip.net/ecrire/?exec=article&id_article=5450)
Transforms to **unicode entities** ``.
The interest of this filter is that it does not impact html tags.
`2 est "supérieur" à 1`

`2 est "supérieur" à 1`

**echapper_tags**
(https://www.spip.net/ecrire/?exec=article&id_article=5515)
Transforms the tag chevrons `<...>` into an HTML entity.
Useful for text between tags. `<pre>`.
`<strong>William Shakespeare</strong> naquit à Stratford-sur-Avon`

`&lt;p&gt;&lt;strong&gt;William Shakespeare&lt;/strong&gt; naquit à
Stratford-sur-Avon&lt;/p&gt;`

**PtoBR** (https://www.spip.net/ecrire/?exec=article&id_article=4308)
Transforms paragraph breaks `` into simple line breaks.
Allows you to "tighten" a layout.
`<strong>William Shakespeare :</strong><p style="color:navy;">né à
Stratford-sur-Avon `

`<strong>William Shakespeare :</strong><br>né à Stratford-sur-Avon`

**lignes_longues**
(https://www.spip.net/ecrire/?exec=article&id_article=4298)
Introduces **caesura** in the "too long" words..
`http://www.spip.net/spip.php?page=recherche&recherche=lignes_longues`

    http://www.spip.net
    /spip.
    php?page=recherche
    &recherche=lignes_longues

**liens_absolus**
(https://www.spip.net/ecrire/?exec=article&id_article=4126)
Transforms **all links** (`<a href=...`, `<link href:...`, `<img src=...`
and `<script src=...`) into absolute links.
Particularly useful in RSS feed skeletons.
`<img src="IMG/arton01.jpg">`

`<img src="http://lesite.com/IMG/arton01.jpg">`

**liens_ouvrants**
(https://www.spip.net/ecrire/?exec=article&id_article=4297)
Transforms **SPIP links** that lead to external sites to open in a new
window or tab.
`<a href="http://www.spip.net/page.html">`

`<a href="http://www.spip.net/page.html" target="_blank">`

---------------------------------------------------------------------------

**P.-S.**
See also the complete list of all filters : SPIP Filters
(https://www.spip.net/ecrire/?exec=article&id_article=901)

## Documents joints

* **Une noisette pour tester-valider les exemples. ** (HTML - 1.2 ko )
(https://www.spip.net/IMG/html/page-test.html)
    Utilisation par ?page=contenu/page-test
    
    (et penser à visualiser le source HTML produit par SPIP)

— Envoyé par SPIP (https://www.spip.net/)

rubon199.jpg