L'evidenziazione della sintassi non viene copiata quando si incolla in un luogo che supporta il testo colorato

Quando ho copiato quanto riportato di seguito, da Discourse, al mio client di posta elettronica:

@@ -1,11 +1,11 @@
-Premio Giovane Volontario – per celebrare i giovani volontari, tra i 16 e i 24 anni, che fanno un passo in più nelle loro comunità locali, dimostrando i nostri valori e l'importanza della connessione e dell'azione.
+Il Premio Giovane Volontario celebra i giovani volontari, tra i 16 e i 24 anni, che fanno un passo in più nelle loro comunità locali, dimostrando i nostri valori e l'importanza della connessione e dell'azione.
 
 Conosci un giovane che:
 
-È stato volontario con Neighbourhood Watch e ha avuto un impatto positivo nella sua comunità.
+• È stato volontario con Neighbourhood Watch e ha avuto un impatto positivo nella sua comunità?
 
-Donare il proprio tempo per sostenere la propria comunità locale (banchi alimentari, centri e gruppi comunitari, senzatetto, gruppi religiosi)
+• Donare il proprio tempo per sostenere la propria comunità locale (banchi alimentari, centri e gruppi comunitari, senzatetto, gruppi religiosi)?
 
-Ha organizzato attività di raccolta fondi con la propria scuola o università o ha organizzato raccolte di rifiuti o altri eventi locali.
+• Ha organizzato attività di raccolta fondi con la propria scuola o università o ha organizzato raccolte di rifiuti o altri eventi locali?
 
-Pensi che questo giovane volontario meriti di essere riconosciuto per il suo duro lavoro e il suo impegno verso la comunità.
+In tal caso, pensi che questo giovane volontario meriti di essere riconosciuto per il suo duro lavoro e il suo impegno verso la comunità?

…non ha replicato la colorazione.

Hai usato diff? Forse il tuo client di posta non lo supporta?

- qui c'è del testo
+ qui c'è del testo in più

@Lilly, sì. Su Discourse è necessario specificare diff affinché la colorazione venga resa:

  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?
    

Ti riferisci al fatto che io scriva CommonMark nel mio client?

In tal caso, sarebbe di competenza di un altro luogo:

Invece, mi riferisco al copia-incolla diretto dal markup renderizzato qui, come ad esempio:

sì, ovviamente lo so, ed è per questo che te lo chiedevo

@Lilly, puoi vedere, in /1, che l’ho utilizzato, comunque.

Oh, mi scuso, inizialmente pensavo fosse uno screenshot.

1 Mi Piace

Oggi, dipende da come lo copi.

Usando il pulsante Copia:

vengono inseriti nella clipboard solo il testo e altri elementi, tra cui:

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

ma copiare il testo effettivo funziona:

poiché stai copiando l’HTML renderizzato direttamente tramite il browser, invece di far interagire Discourse con la clipboard, il formato text/HTML è disponibile per i consumatori della clipboard:

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

Per supportare questa funzionalità tramite il pulsante Copia, dovremmo aggiungere la possibilità di prendere la versione colorizzata renderizzata (poiché la colorazione è gestita da una libreria) e inviarla alla clipboard nel formato text/html. È probabilmente possibile (forse anche come componente del tema), ma nel frattempo c’è sempre l’opzione di copiare selezionando il testo.

3 Mi Piace

@supermathie, grazie. Allora, sembra che il problema sia il mio client (protonMail/webClients, 5.0.115.3 β):

Screencast20260522180439

Tuttavia, la colorazione non riesce a duplicarsi nemmeno in thunderbird-149.0.1-2.fc44, nonostante sembri funzionare per te:

Hai idea di cosa fai diversamente, se fai qualcosa di diverso?

Quando copi su ProtonMail, essendo un client web, sembra che stia utilizzando la versione in testo semplice. Nota la mancanza di differenziazione nella formattazione, anche se è difficile da dire poiché stai sovrascrivendo i caratteri.

Confronta con l’incollamento su Thunderbird:

Rileva alcune delle impostazioni di formattazione, ma non tutte.

Se invece copio, rileva tutto:

Penso che per capire la questione, si debba distinguere se:

  • non tutti gli stili vengono copiati
  • non tutti gli stili vengono incollati

Partire da un browser pulito, senza estensioni, potrebbe aiutare a capire? Ad esempio, se uso un browser privato senza estensioni ecc., ottengo:

Questo script che ho scritto ti darà anche visibilità sugli appunti, il che potrebbe essere d’aiuto.

(o forse Arch » Fedora :face_with_tongue:)

1 Mi Piace

@supermathie, questo succede perché il foglio di stile predefinito di ProtonMail è terribile.

Come da tua indicazione, ho accertato che è lo stesso Firefox (nemmeno il mio profilo, dato che il problema si riproduce con un nuovo profilo in about:profiles) a non riuscire a copiarlo:

Grazie mille!

Esatto! Ho lo stesso comportamento.

E, parlando strettamente, non è un bug. Firefox sta copiando l’HTML esattamente come richiesto:

<meta http-equiv="content-type" content="text/html; charset=utf-8">
<p dir="auto">Quando ho copiato quanto riportato di seguito, da Discourse, nel mio client di posta elettronica:</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 differenza risultante dopo l’incollatura deriva da Chromium che applica gli stili in linea, mentre Firefox no. Riducendo tutto a una singola riga si evidenzia[1] cosa sta succedendo:

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

(a capo aggiunti)

Chromium applica in linea, partendo da class="hljs-deletion", lo stile CSS inline style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 224, 224); color: rgb(192, 45, 46);" allo span, poiché probabilmente ciò in cui sta incollando non dispone di quello stile.


  1. eh ↩︎