No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Vous devez être membre et vous identifier pour publier un article.
Les visiteurs peuvent toutefois commenter chaque article par une réponse.

Les guillemets en CSS

Astuces de l’Infobrol (Développement)Article publié le 07/06/2010 09:20:29


Situation


Afin de générer des guillemets corrects en fonction de la langue du texte mis en exergue, je définissait jusqu’à présent le type dans une feuille de style comme ceci :

  1. q,blockquote,span:lang(fr),span[xml\:lang="fr"],span:lang(la),span[xml\:lang="la"]{quotes:"\00ab" "\00bb";}
  2. q:lang(en),blockquote:lang(en),span:lang(en),q[xml\:lang="en"],blockquote[xml\:lang="en"],span[xml\:lang="en"]{quotes:"\201c" "\201d";}
  3. q:lang(de),blockquote:lang(de),span:lang(de),q[xml\:lang="de"],blockquote[xml\:lang="de"],span[xml\:lang="de"]{quotes:"\201e" "\201c";}
  4. span[xml\:lang="fr"]:before,span[xml\:lang="la"]:before,span[xml\:lang="en"]:before,span[xml\:lang="de"]:before{content:open-quote;}
  5. span[xml\:lang="fr"]:after,span[xml\:lang="la"]:after,span[xml\:lang="en"]:after,span[xml\:lang="de"]:after{content:close-quote;}
  6. blockquote:before{content:open-quote;font-weight:bold;}
  7. blockquote:after{content:close-quote;font-weight:bold;}


De toute manière, je fais appel à une méthode php de l’instance ma classe page, comme ceci :

  1. /**
  2. * @param String $text text to quote
  3. * @param String $lang Iso 3166 language code [optional, default=’fr’]
  4. * @param String $tag (X)HTML wrapper tag [optional, default=’span’]
  5. * @param String $css style to apply to the wrapper tag [optional, default=’’]
  6. * @return String text surrounded by tag and localized quotes
  7. * @since 20080119
  8. * @version 20100528
  9. */
  10. public function getQuotedTag($text,$lang=’fr’,$tag=’span’, $css=’’){
  11. $lgInfo=$this-›getLanguage($lang, Language::$ISO3166);
  12. $t= ’‹’.$tag;
  13. $t.=’ xml:lang="’.$lang-›getCode().’"’;
  14. $t.=’ title="terme ’.$lgInfo-›getFrenchName().’"’;
  15. if($css!==’’){
  16. $t.=’ class="’.$css.’"’;
  17. }
  18. $t.=’›’.$lgInfo-›getQuoteBefore().$text.$lgInfo-›getQuoteAfter().’‹/’.$tag.’›’;
  19. return $t;
  20. }

Ce qui me permet de travailler comme ceci dans ma page php :
  1. echo ’‹p›Ceci est un texte ’.$page-›getQuotedTag(’entre guillemets’).’, et nous pouvons aussi avoir ’;
  2. echo ’des extraits ’.$curPge-›getQuotedTag(’of english words’,Language::$EN).’.‹/p›’;


Problème


Sous Internet Explorer, les guillemets en tant que contenu généré en CSS ne sont pas pris en compte.
De toute manière, les guillemets ont une valeur sémantique, et donc dépendent plus de la page elle même que de sa présentation. Pour des balises comme blockquote ou q, la sémantique est claire, et les guillemets peuvent se trouver dans la CSS, mais dans le cas d’un extrait de texte qui n’est pas une citation mais quand même entre guillemets pour le mettre en exergue?

Solution adoptée


J’ai donc décidé de modifier ma fonction php pour afficher "en dur" les guillemets, et de supprimer ceux qui sont ajoutés automatiquement par les (bons) navigateurs.

  1. q:before,blockquote:before,q:after,blockquote:after{content:"";}


Comme je fais un appel à la fonction dans mes pages, je dois simplement modifier la classe Language. Avant les méthodes getQuoteBefore et getQuoteAfter retournaient une chaîne de caractère vide en anglais, ou un espace en français, etc. A présent ces méthodes retournent le type de guillemet ouvrant et fermant.

Avatar :: Steph Un article de Steph

Source : indéterminée


Sélection, tri et recherche d'articles
FILTRER :
TRIER :1er critère : 2e critère :
CHERCHER : Dans les titres Dans le contenu


[Afficher les liens en fonction des critères du formulaire ci-dessus]

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 13/09/2004, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/ast-rf-460.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.