La coloration syntaxique n'est pas conservée lors du copier-coller vers un endroit prenant en charge le texte coloré

Lorsque j’ai copié ce qui suit, depuis Discourse, dans mon client de messagerie :

@@ -1,11 +1,11 @@
-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
+The Young Volunteer Award celebrates young volunteers, aged 16–24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
 
 Do you know a young person who:
 
-Has been volunteering with Neighbourhood Watch and making a positive impact in their community.
+• Has been volunteering with Neighbourhood Watch and making a positive impact in their community?
 
-Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)
+• Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)?
 
-Held fundraising activities with their school or college or have organised litter picks or other local events.
+• Held fundraising activities with their school or college or have organised litter picks or other local events?
 
-You think this young volunteer deserves to be recognised for their hard work and commitment to their community.
+If so, do you think this young volunteer deserves to be recognised for their hard work and commitment to their community?

…la coloration n’a pas été reproduite.

As-tu utilisé diff ? Peut-être que ton client de messagerie ne le prend pas en charge ?

- voici du texte
+ voici un peu plus de texte

@Lilly, oui. Spécifier diff est requis pour que la coloration syntaxique s’affiche correctement sur Discourse :

  1. ```
    @@ -1,11 +1,11 @@
    -Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
    +The Young Volunteer Award celebrates young volunteers, aged 16–24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
     
     Do you know a young person who:
     
    -Has been volunteering with Neighbourhood Watch and making a positive impact in their community.
    +• Has been volunteering with Neighbourhood Watch and making a positive impact in their community?
     
    -Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)
    +• Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)?
     
    -Held fundraising activities with their school or college or have organised litter picks or other local events.
    +• Held fundraising activities with their school or college or have organised litter picks or other local events?
     
    -You think this young volunteer deserves to be recognised for their hard work and commitment to their community.
    +If so, do you think this young volunteer deserves to be recognised for their hard work and commitment to their community?
    ```
    
  2. @@ -1,11 +1,11 @@
    -Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
    +The Young Volunteer Award celebrates young volunteers, aged 16–24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
     
     Do you know a young person who:
     
    -Has been volunteering with Neighbourhood Watch and making a positive impact in their community.
    +• Has been volunteering with Neighbourhood Watch and making a positive impact in their community?
     
    -Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)
    +• Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)?
     
    -Held fundraising activities with their school or college or have organised litter picks or other local events.
    +• Held fundraising activities with their school or college or have organised litter picks or other local events?
     
    -You think this young volunteer deserves to be recognised for their hard work and commitment to their community.
    +If so, do you think this young volunteer deserves to be recognised for their hard work and commitment to their community?
    

Parlez-vous de ma rédaction en CommonMark dans mon client ?

Si c’est le cas, cela relève d’un autre domaine :

En revanche, je fais référence à la copie directe depuis le rendu du balisage ici, comme :

Oui, je le sais évidemment, c’est pourquoi je te posais la question.

@Lilly, tu peux voir, dans /1, que je l’ai utilisé, cependant.

Oh, mes excuses, j’ai d’abord cru que c’était une capture d’écran.

1 « J'aime »

Aujourd’hui, cela dépend de la façon dont vous le copiez.

En utilisant le bouton Copier :

seule la version textuelle est placée dans le presse-papiers, entre autres :

TIMESTAMP,TARGETS,SAVE_TARGETS,MULTIPLE,UTF8_STRING,STRING,TEXT,text/plain,text/plain;charset=utf-8,chromium/x-internal-source-rfh-token,chromium/x-source-url

mais copier le texte réel fonctionne :

puisque vous copiez le HTML rendu via le navigateur au lieu que Discourse interagisse avec le presse-papiers, le format text/html est disponible pour les consommateurs du presse-papiers :

<span class="hljs-meta" style="color: rgb(133, 133, 133); font-style: italic; font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">@@ -1,11 +1,11 @@</span><span style="color: rgb(199, 199, 199); font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-style: normal; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; background-color: rgba(0, 0, 0, 0.25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">\n</span><span class="hljs-deletion" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(79, 24, 11); color: rgb(222, 113, 118); font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-style: normal; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.</span><span style="color: rgb(199, 199, 199); font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-style: normal; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; background-color: rgba(0, 0, 0, 0.25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">\n</span><span class="hljs-addition" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(11, 66, 32); color: rgb(118, 196, 144); font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-style: normal; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">+The Young Volunteer Award celebrates young volunteers, aged 16–24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.</span><span style="color: rgb(199, 199, 199); font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-style: normal; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; background-color: rgba(0, 0, 0, 0.25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">\n</span><br class="Apple-interchange-newline">

Pour prendre en charge cela via le bouton Copier, nous devrions ajouter la possibilité de récupérer la version colorisée rendue (puisque la colorisation est effectuée par une bibliothèque) et de l’envoyer au presse-papiers avec le format text/html. C’est probablement possible (peut-être même en tant que composant de thème), mais en attendant, il y a toujours la possibilité de copier en sélectionnant le texte.

3 « J'aime »

@supermathie, merci. Alors, le problème semble provenir de mon client (protonMail/webClients, 5.0.115.3 β) :

Screencast20260522180439

Cependant, la coloration échoue également à se dupliquer dans thunderbird-149.0.1-2.fc44, même si elle semble fonctionner pour vous :

Avez-vous une idée de ce que vous faites différemment, le cas échéant ?

Lorsque vous copiez dans ProtonMail, qui est un client web, cela ressemble à l’utilisation de la version texte brut. Notez l’absence de différenciation de mise en forme, bien qu’il soit difficile de le juger puisque vous remplacez les polices.

Comparez avec le collage dans Thunderbird :

Il récupère certaines parties de la mise en forme, mais pas toutes.

Si je copie, il récupère tout :

Je pense que pour comprendre cela, il faut déterminer si :

  • tous les styles ne sont pas copiés
  • tous les styles ne sont pas collés

Commencer avec un navigateur propre, sans extensions, pourrait aider à clarifier la situation ? Par exemple, si j’utilise un navigateur privé sans extensions, etc., j’obtiens :

ce script que j’ai écrit vous donnera également une visibilité sur le presse-papiers, ce qui pourrait aider.

(ou peut-être Arch » Fedora :face_with_tongue:)

1 « J'aime »

@supermathie, c’est parce que la feuille de style par défaut de ProtonMail est affreuse.

Suite à vos conseils, j’ai constaté que Firefox lui-même (et pas seulement mon profil, car le problème se reproduit avec un nouvel utilisateur dans about:profiles) échoue à le copier :

Je vous suis très reconnaissant !

Oui ! Je constate le même comportement.

Et, strictement parlant, ce n’est pas un bug. Firefox copie le HTML exactement tel que demandé :

<meta http-equiv="content-type" content="text/html; charset=utf-8">
<p dir="auto">Lorsque j'ai copié ce qui suit, depuis Discourse, vers mon client de messagerie :</p>
<pre data-code-wrap="diff" dir="auto" class="codeblock-buttons">
		<div class="codeblock-button-wrapper" style="right: 0px;"></div>
		<code class="lang-diff hljs language-diff" data-highlighted="yes">
			<span class="hljs-meta">@@ -1,11 +1,11 @@</span>
			<span class="hljs-deletion">-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.</span>
			<span class="hljs-addition">+The Young Volunteer Award celebrates young volunteers, aged 16–24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.</span>
		</code>
	</pre>

La différence résultante après le collage provient du fait que Chromium intègre les styles en ligne, tandis que Firefox ne le fait pas. Réduire cela à une seule ligne met en évidence[1] ce qui se passe :

<span
  class="hljs-deletion">
-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
</span>
<span
  class="hljs-deletion"
  style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 224, 224); color: rgb(192, 45, 46);">
-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
</span>

(sauts de ligne ajoutés)

Chromium intègre depuis class="hljs-deletion" le style CSS en ligne style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 224, 224); color: rgb(192, 45, 46);" dans le span, car ce dans quoi il colle n’a probablement pas ce style.


  1. hein ↩︎