Skip to main content
Participant
Jan 21, 2025 1:00 PM UTC
Answered

Grep espace insecable après sujet

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 !

FRIdNGE
FRIdNGECorrect answer
Jan 21, 2025 2:09 PM UTC

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

 

(^/)  The Jedi

23 replies

JR Boulay
Community Expert
Community Expert
Jan 22, 2025 8:52 AM UTC

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/

 

Translate
Acrobate du PDF, InDesigner et Photoshopographe
Community Expert
Jan 22, 2025 11:18 AM UTC

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.

Translate
Robert at ID-Tasker
Legend
Jan 22, 2025 11:34 AM UTC
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? 

 

Translate
Robert at ID-Tasker
Legend
Jan 21, 2025 2:12 PM UTC

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

 

Translate
Participant
Jan 21, 2025 2:25 PM UTC

ok comment ?

Translate
Robert at ID-Tasker
Legend
Jan 21, 2025 2:34 PM UTC
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.

 

Translate
FRIdNGE
FRIdNGECorrect answer
Jan 21, 2025 2:09 PM UTC

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

 

(^/)  The Jedi

Translate
Participant
Jan 21, 2025 2:26 PM UTC

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

Translate
Community Expert
Jan 21, 2025 3:11 PM UTC

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

Translate
Peter Spier
Community Expert
Community Expert
Jan 21, 2025 2:04 PM UTC

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?

Translate
Participant
Jan 21, 2025 2:25 PM UTC

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

Translate