Skip to main content
Participant
January 21, 2025
Answered

Grep espace insecable après sujet

  • January 21, 2025
  • 4 replies
  • 1321 views

Bonjour j'aimerai connaitre la formule grep pour remplacer une espace normale par une espace insécable après des sujets ou des déterminants. C'est à dire que j'ai plein de paragraphe ou la ligne se termine par "elle", "au" "du" ou "sur" et j'aimerai automatiser pour que ces mots aillent à la ligne pour que la lecture soit plus facile. Help !

Correct answer FRIdNGE

(?i)\b(elle|au|du|sur)\K\h

 

(^/)  The Jedi

4 replies

JR Boulay
Community Expert
Community Expert
January 22, 2025

Comme indiqué ci-dessus par Robert at ID-Tasker il serait plus productif d'utiliser un style GREP qui applique l'attribut "sans retour" (no break) à l'espace suivant les mots concernés.

 

Plus productif car les espaces insécables peuvent poser problème pour certains logiciels d'accessibilité qui lisent le texte à voix haute, et surtout parce-qu'ainsi c'est un attribut dynamique qu'il n'y a pas besoin d'appliquer après chaque modification du texte. Une fois un tel style GREP intégré au style de paragraphe il n'y a plus besoin d'y penser.

 

Par-contre vous risquez d'avoir des infractions de justification et des espacements indésirables.

 

Avec les formules données ci-dessus et l'explication détaillée (en français) dans cet article vous devriez y arriver facilement :

https://www.abracadabrapdf.net/ressources-et-tutos/abracadabragrep/grep-pour-indesign-anti-mot-orphelin/

 

Acrobate du PDF, InDesigner et Photoshopographe
Community Expert
January 22, 2025

Didn't realise about the accessibility - good to know. 

There's caveats with every workflow, and sometimes in long documents Grep Styles can cause slow down with text reflows too. Just worth noting.

Robert at ID-Tasker
Legend
January 22, 2025
quote

There's caveats with every workflow, and sometimes in long documents Grep Styles can cause slow down with text reflows too. Just worth noting.


By @Eugene Tyson

 

I thought that this has been disproved? 

 

Robert at ID-Tasker
Legend
January 21, 2025

It can also be done with a GREP Style and an extra CharStyle. 

 

Participant
January 21, 2025

ok comment ?

Robert at ID-Tasker
Legend
January 21, 2025
quote

ok comment ?


By @Camille26199799mfhz

 

I'm not a GREP expert and I can't find past posts about that - but I'm sure some will post a solution.

 

FRIdNGE
FRIdNGECorrect answer
January 21, 2025

(?i)\b(elle|au|du|sur)\K\h

 

(^/)  The Jedi

Participant
January 21, 2025

je vais tester merci mais c'est vrai que je pensais à une formule qui ne m'oblige pas à rentrer chaque mot spécifique mais en tout cas c'est déjà une solution merci beaucoup

Community Expert
January 21, 2025

The only way I can think to automate it without inserting each word is to find and replace by character length, the below finds between 1 and 4 characters and inserts a non-breaking space after it. 

 

Find

\b\w{1,4}\K\h

Replace with

~S

Peter Spier
Community Expert
Community Expert
January 21, 2025

Do you want to do this only after those specific words, or is this soemthing you wand to do for any word shorter than 5 characters?

Participant
January 21, 2025

ce sont normalement des mots spécifiques commes les déterminants ou les sujets mais ça pourraient marcher si on parle de mots de moins de 4 lettres